refactor proof options to theorem options

This commit is contained in:
gluax 2021-07-02 15:26:13 -07:00
parent 45f75ef33a
commit 41f4eed360
3 changed files with 27 additions and 27 deletions

View File

@ -22,7 +22,7 @@ use crate::{
GroupType,
Output,
OutputFile,
ProofOptions,
TheoremOptions,
TypeInferencePhase,
};
pub use leo_asg::{new_context, AsgContext as Context, AsgContext};
@ -67,7 +67,7 @@ pub struct Compiler<'a, F: PrimeField, G: GroupType<F>> {
context: AsgContext<'a>,
asg: Option<AsgProgram<'a>>,
options: CompilerOptions,
proof_options: ProofOptions,
proof_options: TheoremOptions,
_engine: PhantomData<F>,
_group: PhantomData<G>,
}
@ -82,7 +82,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
output_directory: PathBuf,
context: AsgContext<'a>,
options: Option<CompilerOptions>,
proof_options: Option<ProofOptions>,
proof_options: Option<TheoremOptions>,
) -> Self {
Self {
program_name: package_name.clone(),
@ -112,7 +112,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
output_directory: PathBuf,
context: AsgContext<'a>,
options: Option<CompilerOptions>,
proof_options: Option<ProofOptions>,
proof_options: Option<TheoremOptions>,
) -> Result<Self, CompilerError> {
let mut compiler = Self::new(
package_name,
@ -151,7 +151,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
state_path: &Path,
context: AsgContext<'a>,
options: Option<CompilerOptions>,
proof_options: Option<ProofOptions>,
proof_options: Option<TheoremOptions>,
) -> Result<Self, CompilerError> {
let mut compiler = Self::new(
package_name,

View File

@ -38,13 +38,13 @@ impl Default for CompilerOptions {
}
#[derive(Clone)]
pub struct ProofOptions {
pub struct TheoremOptions {
pub initial: bool,
pub canonicalized: bool,
pub type_inferenced: bool,
}
impl Default for ProofOptions {
impl Default for TheoremOptions {
fn default() -> Self {
Self {
initial: false,

View File

@ -19,7 +19,7 @@ use leo_compiler::{
compiler::{thread_leaked_context, Compiler},
group::targets::edwards_bls12::EdwardsGroupType,
CompilerOptions,
ProofOptions,
TheoremOptions,
};
use leo_package::{
inputs::*,
@ -44,14 +44,14 @@ pub struct BuildOptions {
pub disable_code_elimination: bool,
#[structopt(long, help = "Disable all compiler optimizations")]
pub disable_all_optimizations: bool,
#[structopt(long, help = "Enables all json ast proof generations.")]
pub enable_all_proofs: bool,
#[structopt(long, help = "Enables the initial parsed json ast proof generation.")]
pub enable_initial_proof: bool,
#[structopt(long, help = "Enables the post canonicalization json ast proof generation.")]
pub enable_canonicalized_proof: bool,
#[structopt(long, help = "Enables the post canonicalization json ast proof generation.")]
pub enable_type_inferenced_proof: bool,
#[structopt(long, help = "Writes all theorem input AST files.")]
pub enable_all_theorems: bool,
#[structopt(long, help = "Writes AST files needed for the initial theorem before any changes.")]
pub enable_initial_theorem: bool,
#[structopt(long, help = "Writes AST files needed for canonicalization theorem.")]
pub enable_canonicalized_theorem: bool,
#[structopt(long, help = "Writes AST files needed for type inference theorem.")]
pub enable_type_inferenced_theorem: bool,
}
impl Default for BuildOptions {
@ -60,10 +60,10 @@ impl Default for BuildOptions {
disable_constant_folding: true,
disable_code_elimination: true,
disable_all_optimizations: true,
enable_all_proofs: false,
enable_initial_proof: false,
enable_canonicalized_proof: false,
enable_type_inferenced_proof: false,
enable_all_theorems: false,
enable_initial_theorem: false,
enable_canonicalized_theorem: false,
enable_type_inferenced_theorem: false,
}
}
}
@ -86,19 +86,19 @@ impl From<BuildOptions> for CompilerOptions {
}
}
impl From<BuildOptions> for ProofOptions {
impl From<BuildOptions> for TheoremOptions {
fn from(options: BuildOptions) -> Self {
if options.enable_all_proofs {
ProofOptions {
if options.enable_all_theorems {
TheoremOptions {
initial: true,
canonicalized: true,
type_inferenced: true,
}
} else {
ProofOptions {
initial: options.enable_initial_proof,
canonicalized: options.enable_canonicalized_proof,
type_inferenced: options.enable_type_inferenced_proof,
TheoremOptions {
initial: options.enable_initial_theorem,
canonicalized: options.enable_canonicalized_theorem,
type_inferenced: options.enable_type_inferenced_theorem,
}
}
}