A logic consistency solving method and system based on a large language model
By transforming the propositional logic satisfiability problem into a conjunctive normal form formula and generating natural language prompts using a large language model, combined with a variable consistency rate and a controllable random masking mechanism, the problem of high computing power consumption during SAT solving is solved, achieving efficient SAT solving.
Patent Information
- Application Number
- CN202611663519.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-27
- Publication Date
- 2026-11-24
AI Technical Summary
Existing SAT solving techniques consume a lot of computing power when dealing with propositional logic satisfiability problems with large-scale variables, making it difficult to meet the low latency requirements of practical systems. Furthermore, traditional incomplete solvers fail to effectively utilize the semantic information between variables.
By using a logic consistency solution method based on a large language model, the propositional logic satisfiability problem is transformed into a conjunctive normal form formula, generating natural language prompt text. The large language model is used to process the Boolean variable assignments, and the masking rate and number of restarts are determined based on the variable consistency rate. Initial assignments are generated by combining a controllable random masking mechanism, and incomplete solutions are performed.
It significantly reduces the computing power consumption of the SAT solving process, improves the solving efficiency, takes into account the semantic prior advantages of large language models and the random exploration ability of traditional incomplete solving algorithms, and improves the probability of successful solution.
Smart Images

Figure CN123158019A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large language model technology, and in particular to a method and system for solving logical consistency problems based on large language models. Background Technology
[0002] The incomplete solution method for the propositional logic satisfiability problem (SAT problem) can be widely used in electronic design automation for equivalence testing, formal verification, automatic theorem proving, consistency verification of behavioral constraints of agents, planning and scheduling, cryptographic analysis, and fact / logic consistency detection of Large Language Model (LLM) outputs.
[0003] The formal definition of the SAT problem is: given a set of SAT questions... The problem asks whether there exists a set of values for a formula in Conjunctive Normal Form (CNF) consisting of 8 Boolean variables, making the entire formula true. The SAT problem was the first problem in computer science to be proven NP-complete (Cook–Levin theorem, 1971). In real-world scenarios, the number of variables is... Reachable to The magnitude and solution efficiency directly determine the feasibility of downstream applications.
[0004] Currently, mainstream SAT solving techniques can be broadly divided into two routes. The first route is the complete solver route, represented by Conflict-Driven Clause Learning (CDCL). Representative implementations of this route include MiniSAT, Glucose, and Kissat. Its core mechanisms encompass unit propagation, conflict analysis and clause learning, non-temporal backtracking, VSIDS branch heuristics, and dual-monitor literals. CDCL solvers can provide both satisfiability and non-satisfiability decisions, but their worst-case complexity remains exponential. In scenarios outside of industrial applications, such as random 3-SAT at critical ratios On nearby instances, the solution time would increase exponentially, making it difficult to meet the low latency requirements of real-world systems.
[0005] The second approach is the incomplete solver route represented by the random walk algorithm proposed by Schöning in 1999. This algorithm first uniformly and randomly generates a set of initial assignments for each trial, and then performs at most [number missing] operations on those initial assignments. Step-by-step local flipping: At each step, first check if the current assignment makes the formula true. If true, return immediately; otherwise, randomly select an unsatisfied clause, uniformly select a literal from that clause, and flip the value of its corresponding variable. Schöning's proof: For any satisfyable... The CNF formula, starting from uniform random initialization, states that the probability of success in a single trial is at least 1 / 3. Therefore, repeat This will ensure that the overall success rate is not less than [percentage missing]. For the most common 3-SAT, this upper bound is approximately... It was the upper bound of the then-known optimal incomplete 3-SAT algorithm.
[0006] Both of the aforementioned mainstream approaches have significant shortcomings in practical applications. CDCL-type complete solvers experience exponentially faster solution times for random or poorly structured instances, failing to meet the need for rapid decision-making under time-delay constraints. While Schöning-type incomplete solvers provide a probabilistic upper bound for the worst-case scenario, their initial assignments use a completely uniform random distribution, failing to utilize the semantic information inherent in the problem itself. In many real-world tasks, such as behavioral constraint verification of agents, knowledge base consistency checks, and executability determination of natural language rules, significant natural language-level correlations exist between variables: some variables semantically almost exclusively take only one value, while others exhibit common-sense implications. However, the Schöning algorithm is completely unaware of this information; the expected Hamming distance between its initial assignment and the nearest satisfiable solution remains constant. We must rely on Only a number of restarts of that magnitude can ensure a stable escape. Summary of the Invention
[0007] Based on the above analysis, the embodiments of the present invention aim to provide a logical consistency solution method and system based on a large language model, so as to solve the problem of high computer computing power consumption in the SAT solution process in the prior art.
[0008] On one hand, embodiments of the present invention provide a logical consistency solution method based on a large language model, comprising: obtaining a propositional logic satisfiability problem input by a user; converting the propositional logic satisfiability problem into a conjunctive normal form formula of satisfiability equivalence; generating natural language prompt text based on the conjunctive normal form formula; processing the natural language prompt text using a large language model to obtain the Boolean assignments of each Boolean variable in the conjunctive normal form; calculating the variable-wise consistency rate of the Boolean assignments relative to the benchmark witness, and determining the mask rate and the number of restarts required for the solution based on the variable-wise consistency rate; for each restart, generating a mask according to the mask rate, initially assigning Boolean values to Boolean variables marked as valid in the mask, and randomly initializing Boolean variables marked as invalid in the mask to obtain the initial assignments corresponding to the current restart; performing propositional logic satisfiability incompleteness solution based on the number of restarts and the initial assignments corresponding to each restart to determine the satisfiable solution of the conjunctive normal form formula.
[0009] Furthermore, generating natural language prompt text based on the conjunctive normal form formula includes: determining whether there is an original context corresponding to the conjunctive normal form formula; if there is an original context, constructing a mapping table between Boolean variables and semantic entities in the original context using the original context, replacing Boolean variables and transcribing logical relations using the mapping table to generate natural language prompt text; if there is no original context, transcribing Boolean variables and logical relations using a preset template to generate natural language prompt text.
[0010] Further, determining the variable consistency rate of the Boolean assignment relative to the benchmark witness includes: obtaining a point estimate of the variable consistency rate; calculating the statistical confidence lower bound of the point estimate, and using the statistical confidence lower bound as the variable consistency rate.
[0011] Furthermore, determining the masking rate and the number of restarts required for solving based on the one-variable consistency rate includes: determining the data source for point estimation; wherein the data source includes at least one of the following: statistical data of similar historical instances, features of the conjunctive normal form formula, and correlation features of the output of the large language model; when the data source is statistical data of similar historical instances, obtaining the masking rate and the number of restarts; wherein, before processing the natural language prompt text using the large language model, the masking rate and the number of restarts are calculated based on the one-variable consistency rate; when the data source is the correlation features of the conjunctive normal form formula and the output of the large language model, the masking rate and the number of restarts are calculated based on the one-variable consistency rate.
[0012] Furthermore, the masking rate and the number of restarts are calculated based on the variable consistency rate, including: determining whether the interval to which the variable consistency rate belongs and whether the calibration validity meets the preset requirements, and determining the masking rate based on the determination result; obtaining the solution control parameters, and calculating the number of restarts based on the characteristics of the variable consistency rate, masking rate, solution control parameters and conjunctive normal form formula.
[0013] Further, the masking rate is determined based on the judgment result, including: when the variate consistency rate is within a first preset interval or the calibration validity does not meet the preset requirements, the masking rate is 0; when the variate consistency rate is within a second preset interval and the calibration validity meets the preset requirements, the masking rate is calculated using the following formula: ;in, Let k be the mask rate, and k be the clause length of the conjunctive normal form formula. This represents the consistency rate for each variable.
[0014] Furthermore, solving for the control parameters includes at least the preset target failure probability; the characteristics of the conjunctive normal form formula include at least: clause length and total number of Boolean variables; the number of restarts is calculated based on the variable consistency rate, masking rate, the characteristics of the control parameters and the conjunctive normal form formula, including: calculating the number of restarts using the following formula: ;in, For the number of restarts, Here, n is the total number of Boolean variables, and k is the clause length. For the mask rate, For the consistency rate of each variable, The probability of failure of the target. , .
[0015] Furthermore, generating masks according to the mask rate includes: using the mask rate as a global uniform mask rate and generating Bernoulli masks corresponding to each Boolean variable using the global uniform mask rate; or, using the mask rate as a base mask rate, adjusting the base mask rate according to the weight of each Boolean variable to obtain the independent mask rate corresponding to each Boolean variable, and generating Bernoulli masks respectively using the independent mask rate corresponding to each Boolean variable.
[0016] Furthermore, the initial value is: ;in, This is the initial assignment for the i-th boolean variable during the t-th restart. Assign a Boolean value to the i-th Boolean variable. Let i be the mask label for the i-th boolean variable under the t-th restart. To assign a random initial value to the i-th Boolean variable during the t-th restart. This is the mask rate.
[0017] On the other hand, embodiments of the present invention provide a logic consistency solution system based on a large language model, comprising: a prompting module, used to acquire a propositional logic satisfiability problem input by a user, convert the propositional logic satisfiability problem into a conjunctive normal form formula of satisfiability equivalence, and generate natural language prompt text according to the conjunctive normal form formula; a processing module, used to process the natural language prompt text using a large language model to obtain the Boolean assignments of each Boolean variable in the conjunctive normal form; a calculation module, used to calculate the variable-wise consistency rate of the Boolean assignments relative to the benchmark witness, and determine the mask rate and the number of restarts required for the solution based on the variable-wise consistency rate; an assignment module, used to generate a mask according to the mask rate for each restart, perform initial assignments on Boolean variables marked as valid by the mask using Boolean assignments, and perform random initial assignments on Boolean variables marked as invalid by the mask, to obtain the initial assignments corresponding to the current restart; and a solution module, used to perform propositional logic satisfiability incompleteness solution based on the number of restarts and the initial assignments corresponding to each restart, to determine the satisfiable solution of the conjunctive normal form formula.
[0018] In this invention, the semantic priors obtained from mining a general large language model are integrated into the initial assignment of the SAT solution through a controllable random masking mechanism. The masking rate and the number of solution restarts are determined based on the consistency rate of each variable. This allows for precise control of the reuse ratio of semantic priors, achieving a provable gain in the probability of solution success. Simultaneously, it can automatically degenerate into the original incomplete solution mode, avoiding the negative impact of unusable or poorly assigned semantics from the large language model. This invention combines the advantages of semantic priors from large language models with the random exploration capability of traditional incomplete solution algorithms, solving the problem of high computational consumption in the SAT solution process of traditional schemes, reducing computational consumption, and significantly improving the efficiency of SAT solution.
[0019] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0020] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Figure 1 This is an optional flowchart of a logic consistency solution method based on a large language model, as described in an embodiment of the present invention. Detailed Implementation
[0021] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0022] A specific embodiment of the present invention discloses a method for solving logical consistency based on a large language model. Figure 1 An optional flowchart of the method is shown, such as Figure 1 As shown, it includes: S101: Obtain the propositional logic satisfiability problem input by the user, transform the propositional logic satisfiability problem into a conjunctive normal form (CNF) formula of satisfiability equivalence, and generate natural language prompt text based on the CNF formula. The CNF formula includes multiple clauses, each clause being a disjunction of several literals, where the literals are Boolean variables or negations of Boolean variables. Let the input CNF formula be... It contains n Boolean variables and m clauses, each clause having a length of k. Without loss of generality, the following explanation uses k=3, but the logical consistency solution method based on a large language model of this invention is also applicable to general k; S102: A large language model is used to process the natural language prompt text to obtain the Boolean assignments for each Boolean variable in the conjunctive normal form. The natural language prompt text describing the conjunctive normal form formula is input into the large language model. Based on its semantic understanding capabilities, the large language model performs truth inference on each Boolean variable in the prompt text and outputs the Boolean value (true or false) corresponding to each Boolean variable. This set of Boolean values is the Boolean assignment output by the large language model. This Boolean assignment serves as semantic prior information for solving the SAT, but it is not necessarily a true satisfiable solution of the conjunctive normal form formula. Subsequently, this set of assignments will be selectively reused as the initial assignments for incomplete solutions through a masking mechanism. S103: Calculate the variate consistency rate of the Boolean assignment relative to the benchmark witness, and determine the mask rate and the number of restarts required for the solution based on the variate consistency rate; the mask rate is used to control the reuse ratio of the semantic prior of the large model in the initial assignment of the SAT solution, and the number of restarts is the maximum number of restart rounds for incomplete solutions; S104: For each restart round, a mask is generated according to the masking rate. Boolean variables marked as valid by the mask are initialized with Boolean values, while those marked as invalid are initialized with random values, resulting in the initial values for this restart round. Each restart round constructs initial values. The mask, generated according to the masking rate, is used to selectively reuse the Boolean values output by the large language model. The masking rate controls the proportion of Boolean values reused from the large language model. When the mask is valid, the corresponding Boolean variable directly uses the Boolean value output by the large language model, incorporating the semantic priors mined by the large model into the initial values for this round. When the mask is invalid, the corresponding Boolean variable uses a uniformly random value. Through this masking mechanism, semantic prior information and random information are controllably mixed to construct the initial values for this round. S105: Based on the number of restarts and the initial assignments corresponding to each restart, perform propositional logic satisfiability incompleteness solving to determine the satisfiable solution of the conjunctive normal form formula. The Schöning random walk algorithm is used as an optional implementation of the incompleteness solver. For each restart, a set of initial assignments is generated, and then at most 3n local flips are performed on these initial assignments: each step first checks whether the current assignment makes the formula true; if true, it returns immediately; if false, it randomly selects an unsatisfied clause, uniformly and randomly selects a literal from that clause, and flips the value of its corresponding variable until a satisfiable solution is obtained. If all Boolean variables have invalid mask labels, all Boolean variables are randomly initialized, and the solution process degenerates into the original Schöning random walk algorithm.
[0023] In the above implementation, the semantic priors of the problem mined by the general large language model are incorporated into the initial assignment of SAT solution through a controllable random masking mechanism. The masking rate and the number of solution restarts are determined based on the consistency rate of each variable. This allows for precise control of the reuse ratio of semantic priors, obtaining a provable gain in the probability of solution success. Simultaneously, it can automatically degenerate into the original incomplete solution mode, avoiding the negative impact of unusable or poorly assigned semantics from the large language model. This invention combines the advantages of semantic priors from the large language model with the random exploration capability of traditional incomplete solution algorithms, solving the problem of high computational consumption in the traditional SAT solution process and significantly improving the solution efficiency for propositional logic consistency.
[0024] In a preferred embodiment of the present invention, generating natural language prompt text based on a conjunctive normal form formula includes: determining whether there is an original context corresponding to the conjunctive normal form formula; if there is an original context, constructing a mapping table between Boolean variables and semantic entities in the original context using the original context, replacing Boolean variables and transcribing logical relationships using the mapping table to generate natural language prompt text; if there is no original context, transcribing Boolean variables and logical relationships using a preset template to generate natural language prompt text.
[0025] Receive CNF formula And optional original context, which includes, but is not limited to, natural language task descriptions, knowledge base fragments, and explanations of the business meaning of constraints. In the presence of original context, these are the Boolean variables within the CNF formula. Establish a mapping table M between the Boolean variables in the CNF formula and the semantic entities in the original context (e.g., "Is user A an administrator?", "Is the meeting room occupied at 8 PM?"). →Natural language phrases are used to translate each disjunctive clause. In the absence of the original context, each disjunctive clause constituting the CNF is transcribed into natural language according to a predetermined template. Here, disjunction describes only a single clause; the complete CNF is still a conjunction of multiple clauses. Logical relations are transcribed by converting the formalized mathematical logic symbols (∧, ∨, ¬, etc.) in the CNF formula into readable natural language statements, preserving the original propositional logical relations. For example, the clause " This can be transcribed as "At least one of the following three conditions is true: A is true, or B is false, or C is true". Connect all the transcribed clauses with "and" to form the prompt text P(F) for downstream LLM processing.
[0026] Processing the natural language prompt text includes: calling the LLM to process the prompt text P(F), and requesting it to output the Boolean assignments for each Boolean variable. It can also optionally output the confidence level for each variable. .
[0027] After the LLM outputs a Boolean assignment, the variable consistency rate of the Boolean assignment relative to the benchmark witness is determined, including: obtaining a point estimate of the variable consistency rate; calculating the statistical confidence lower bound of the point estimate, and using the statistical confidence lower bound as the variable consistency rate.
[0028] To facilitate providing a lower bound on the success probability of solving SAT incompleteness problems independently of error correlation, a fixed formula is used in the theoretical analysis. A satisfactory witness This means that a fixed, satisfyable solution is provided, and the witness does not need to be known in advance during the current solution run. Output the LLM. and The proportion of consistent variables out of n is defined as the variable consistency rate. ,Right now , This is the Hamming distance function. In actual operation, the statistical confidence lower bound obtained by offline calibration of this one-variable consistency rate is used. As long as the current instance satisfies The subsequent probability guarantee holds true.
[0029] When LLM outputs Boolean assignments, variables are influenced by CNF constraints and contextual semantics, and errors are correlated. Existing techniques for probabilistic inequalities and probability bound derivations force the assumption that errors are independent before reaching a conclusion. However, in this invention, the variable-wise consistency rate definition only uses correct variables (…). and The total number of consistent variables (the number of variables in the LLM) can be used to establish a lower bound on the success probability without requiring errors in different variables to be independent.
[0030] Specifically, first obtain The point estimate is then used, and its statistical confidence lower bound is taken as the basis for subsequent calculations. The possible paths for point estimation include: first, calculating the univariate agreement rate between the LLM output and the satisfyable witness on historical similar instances with satisfyable witnesses, and stratifying the statistics by instance type; second, mapping features such as confidence, cue length, and clause density of the LLM output to empirical univariate agreement rates through equal probability regression or Platt scaling; and third, using the voting univariate agreement rate from multi-temperature sampling as a calibration feature to calibrate the results, rather than directly equating it to the univariate agreement rate without verification. After obtaining the point estimate, one-sided lower confidence bounds are calculated using Clopper-Pearson intervals, Beta-Binomial posterior quantiles, or validation set bootstrapping. The point estimate representing the consistency rate of the calibration model with respect to the current instance per variable can be obtained from the historical samples or the calibration model mentioned above. This indicates that its confidence level is The one-sided lower confidence bound, i.e., the statistical lower confidence bound, The significance level is indicated by .
[0031] After determining the variable-wise consistency rate, the mask rate and the number of restarts required for the solution are determined based on the variable-wise consistency rate. This includes: determining whether the interval to which the variable-wise consistency rate belongs and whether the calibration validity meets the preset requirements, and determining the mask rate based on the determination results; obtaining the solution control parameters, and calculating the number of restarts based on the characteristics of the variable-wise consistency rate, the mask rate, the solution control parameters, and the conjunctive normal form formula.
[0032] Specifically, the masking rate is determined based on the judgment result, including: when the variable consistency rate is within a first preset interval or the calibration validity does not meet the preset requirements, the masking rate is 0; when the variable consistency rate is within a second preset interval and the calibration validity meets the preset requirements, the masking rate is calculated using the following formula: ;in, Let k be the mask rate, and k be the clause length of the conjunctive normal form formula. This represents the consistency rate for each variable.
[0033] The first preset interval can be selected as [0, 0.5], and the second preset interval can be selected as (0.5, 1). Only when... season , ;like If there is insufficient calibration data, then set the mask rate. It is not allowed to pass The lower bound is artificially raised. As a result, the operating budget is calculated using verifiable conservative parameters rather than uncalibrated confidence levels.
[0034] In another optional embodiment of the present invention, the timing for calculating the masking rate and the number of restarts based on the one-variable consistency rate is optional, and is specifically determined as follows: determining the data source for point estimation; wherein the data source includes at least one of the following: statistical data of historical similar instances, features of the conjunctive normal form formula, and correlation features output by the large language model; when the data source is statistical data of historical similar instances, the masking rate and the number of restarts are obtained; wherein, before processing the natural language prompt text using the large language model, the masking rate and the number of restarts are calculated based on the one-variable consistency rate; when the data source is the correlation features of the conjunctive normal form formula and the output of the large language model, the masking rate and the number of restarts are calculated based on the one-variable consistency rate.
[0035] This invention distinguishes the data sources for estimating the variate consistency rate: when based on historical statistical data of similar instances, the masking rate and number of restarts can be pre-calculated before calling the large language model. During execution, this method only needs to call the masking rate and number of restarts, improving computational efficiency. When based on the conjunctive normal form formula and the correlation features of the large model output, parameter calculation is completed after the large model inference, avoiding the erroneous identification of unobserved instance-level confidence information as known quantities before the call. When the computational budget is fixed and insufficient, the minimum required variate consistency rate is calculated in reverse, allowing for the selection of a stronger large language model, expansion of calibration samples, or reduction of the target failure probability, enhancing the planarability of the solution under limited computational resources.
[0036] In another optional embodiment of the present invention, the solution to the control parameters includes at least a preset target failure probability; the features of the conjunctive normal form formula include at least: clause length and total number of Boolean variables; the number of restarts is calculated based on the variable-wise consistency rate, masking rate, the solution to the control parameters, and the features of the conjunctive normal form formula, including: calculating the number of restarts using the following formula: ;in, Here, n is the total number of Boolean variables, and k is the clause length. For the mask rate, For the consistency rate of each variable, The probability of failure for the target.
[0037] The number of restarts used in this invention can be derived as follows: Let the first Each restart generates a Bernoulli mask independently for each variable. : When using LLM assignment, Uniform random assignment is used. (Note: The original text contains several typographical errors and inconsistencies. A more And set the LLM output relative to The one-variable consistency rate .make This indicates the initial assignment and... The Hamming distance (the number of variables with inconsistent values) is then expected to be: (1) For coordinates correctly assigned by the LLM, the probability of an initial assignment error is: For coordinates incorrectly assigned by LLM, the probability of an initial assignment error is... Therefore, when and When, equation (1) is strictly less than When Schöning initially assigns values purely randomly, each variable has a 50% probability of being wrong, with an expected value of... .
[0038] Combining Schöning random walks with Hamming distance The initial assignment has a success probability of at least 100%. Where k is the clause length, This indicates the initial assignment and the fixed satisfyable solution. The number of variables that can take different values. Indicates by By using the finite-step correction factor generated by the step truncation and taking the expectation of independently generated masks and random initial assignments, we can directly obtain the lower bound of the success probability of the t-th restart: (2) Therefore, let the parameter , Then equation (2) equals the lower bound of the original Schöning single restart success probability. Multiply For any Both have sufficiently small make ;exist Envoy The maximum mask rate is shown in equation (5). Finite-step correction factor The original algorithm is the same as that in this invention, therefore it does not affect the exponential speedup ratio between the two. This derivation only classifies the correct and incorrect variables in the LLM output, without requiring these errors to be independent of each other.
[0039] Under random masked scheduling, the hit set for the t-th restart is: Its scale meets Instead of writing the same value as both upper and lower bounds; the lower bound of the probability of a single successful restart is directly determined by... , , and This indicates that there is no need to set a separate average group size parameter that is not involved in subsequent calculations. When the masks, random initializations, and random walks for each restart are independent, the total success probability of T restarts is the probability of "at least one restart succeeding," i.e. . Let be the success probability of the t-th restart. If each restart uses the same... ,and Then, it is sufficient to satisfy the following formula to guarantee that : (3) Let the original Schöning's failure probability not exceed The upper bound of the required number of restarts is From equation (2), we can see that... Substituting this into equation (3), we can obtain the closed upper bound of the number of restarts: (4) in, , , The finite-step correction factor is defined for equation (2). Equation (4) has the following properties: First, and The relation is an explicit expression, requiring neither the Lambert W function nor binary search; secondly, when Or choose hour, , The algorithm smoothly degenerates to the original Schöning; third, when and At that time, the initial assignment of LLM is itself a satisfactory assignment, and the solver can return directly after checking the initial assignment; fourth, the guarantee of equation (4) is that the current actual variable-wise consistency rate is not lower than the statistical confidence lower bound. As a condition.
[0040] To balance the convenience of static planning and runtime implementation, this invention provides two equivalent implementation versions. One is a closed-form calculation version for the mask rate: (5) Suitable for use according to The maximum mask rate corresponding to the statistical confidence lower bound directly chosen by k.
[0041] In an optional embodiment of the present invention, the mask rate can be set differently according to variable confidence, variable importance, or graph structure. For example, a co-occurrence graph of variables can be constructed: each vertex corresponds to a Boolean variable, and an edge is connected between two variables if they both appear in any clause. , and If they appear together in two clauses, the weight between them can be 2, and the mask rate of the higher-weighted variable can be adjusted accordingly.
[0042] In another optional embodiment of the present invention, overlapping grouping or overlapping masking still applies, that is, the condition of "each variable being hit by LLM exactly once" is no longer used, but rather an independent mask is generated each time the system restarts, and the success rate lower bound is calculated based on the actual mask rate of each variable. When all variables use the same mask rate, equation (2) is used directly. Non-uniformity is adopted. When this happens, equation (2) can be rewritten as the product of the contribution factors of each coordinate. That is, equation (2) is broken down into the probability contribution terms corresponding to each Boolean variable (coordinate), and all of them are multiplied together to obtain the lower bound of the overall success probability, and all variables are no longer forced to share the same mask rate.
[0043] The second version is for positive integer restart counts: (6) in, Represents the set of positive integers. Take the conservative lower bound of equation (2).
[0044] It is suitable to calculate it first by equation (2) during runtime. Then, round up according to equation (6) to obtain the feasible result. It can also be directly calculated from equation (4). .like Then place At this point, equations (2) and (6) degenerate into the lower bound of the single-shot success rate and the upper bound of the number of restarts of the original Schöning, respectively, and it is no longer necessary to base them on n and n. The size is further divided into groupings for degeneration.
[0045] Based on the mask rate obtained above Number of restarts With Boolean variable set The initial assignment for each restart is generated according to the following rules.
[0046] Scenario A ( ): In the t-th restart, for each variable Independent sampling and order Therefore Different restarts They can overlap. When LLM output is used at this time ,when Each time, 0 or 1 is randomly selected again. The complete assignment rule is given by formula (7). The values are regenerated on each restart. With random bits Then assign the initial value The Schöning-style random walk algorithm executes at most The step is randomly flipped. This scheduling does not require each variable to use the LLM exactly once throughout the process, but rather to break up the fixed error patterns of the LLM with an independent mask. The lower bound of equation (2) depends only on the total number of correct variables.
[0047] (7) Scenario B ( (LLM unavailable or insufficient calibration data): Let , so that all Each variable is initialized independently and randomly, degenerating into the original Schöning algorithm. In engineering implementations, additional purely random restarts can be reserved as a safety net in any situation. These restarts do not use LLM and do not affect the gain restarts included in equation (2).
[0048] At most, the initial assignment given above for each restart will be executed. The flipping is performed randomly. The flipping rules used are consistent with the original Schöning formula. Can be written as ,in yes Each clause; It is the extraction of k characters, each character For a certain variable Or its negation Each step first checks whether the current assignment makes... If the assignment is true, return the assigned value immediately as a satisfyable solution; otherwise, select one from the m currently unsatisfied clauses. Then, randomly select one character from its k characters and flip the value of the variable corresponding to that character. If no match is found within the first step, the restart ends and control is returned to the random mask initialization scheduler.
[0049] In another optional embodiment of the present invention, the number of local flipping steps for each restart can be set to... If we want to directly use the lower bound of the probability in this paper, then we take the one corresponding to the original proof. ,other The values need to be verified or proven experimentally. Single-step flipping can be achieved using confidence-weighted, Walk-SAT, or periodic LLM online suggestions as engineering variants, but the theoretical guarantee of equation (2) is not directly invoked without separate proof. Prior sources can be replaced by visual-language models, rule systems, or other models that can output candidate Boolean assignments and have calibrable pervariate consistency rates. This invention is applicable to general k-SAT (k≥3). When embedded in the SMT framework, it can be used as a Boolean skeleton solving layer in conjunction with the upper-level theoretical solver.
[0050] The following is based on , (Right now Taking ) as an example, the results of calculations using formulas (4) and (5) are obtained for different variable scales. Lower bounds of different variable consistency rates The following values are calculated based on the mask rate, number of restarts, and speedup factor relative to the original Schöning method, to demonstrate the speedup effect brought by this invention. The values below are taken from the exponential main term of classical analysis. When using other finite-step correction factors, the absolute number of restarts in the original algorithm and the present invention changes proportionally, and the speedup factor remains unchanged. All values are also based on the current instance's actual variable-wise consistency rate being no less than... This is the premise, and the number of restarts is rounded up.
[0051] when At that time, the original Schöning restart count was approximately 315; , , , At that time, the number of restarts of the present invention was approximately 211, 64, 16, and 4, respectively, corresponding to speed increases of approximately 1.5, 4.9, 19.7, and 78.8 times. At that time, the original number of restarts was approximately The number of restarts corresponding to this invention is approximately 32768, 1024, 32. When At that time, the original number of restarts was approximately The number of restarts corresponding to this invention is approximately , , 1024. When At that time, the original number of restarts was approximately The number of restarts corresponding to this invention is approximately , , , The corresponding optimal mask rate is... At that time ; The larger, The more significant the exponential gain, the better. , At that time, the LLM output itself is a satisfyable assignment.
[0052] In the above implementation, the general LLM output is used as a candidate assignment, and a mixture of variable-wise independent random masking and uniform random initial assignments is used to ensure that the LLM is fixed and related errors do not directly determine all initial assignments. A calibrated conservative lower bound is used. The masking rate is determined by parsing the clause length k. And determined by the probability of target failure. Calculate the number of restarts directly The lower bound of the success probability depends only on the number of variables in the LLM output that are consistent with a certain satisfiable solution, and does not require that the errors of each variable be independent. Or when the calibration results are unreliable The algorithm strictly reverts to the original Schöning. When At that time, choose the appropriate This allows the probability of a single success to be obtained relative to a uniformly random initial assignment. The multiplicative gain, where .
[0053] Compared with existing technologies, this embodiment provides a method for rigorously embedding the natural language semantic prior of general LLM into the initial assignment distribution of the Schöning incomplete solver, thereby bringing the following quantifiable and analytical benefits: (i) The probability of a single successful restart is strictly amplified, and the speedup factor can be verified analytically. Based on the Schöning algorithm, this invention proves that if the variable-wise consistency rate between the LLM output and a certain benchmark is at least... And each variable has a probability If an LLM value is used, or a fair random value is used otherwise, the success probability of a single restart satisfies equation (2). Compared with uniform random initial assignment, its multiplicative gain is... For any Choose according to formula (5) Guaranteed This conclusion calculates the number of correct and incorrect variables separately, and does not mistakenly treat "marginal accuracy" as the probability that all variables are correct at the same time.
[0054] (ii) Provable robustness to systematic biases in LLM. The random masking scheduling proposed in this invention can limit the impact of fixed biases when there are inter-variable correlation errors in the LLM output. Specifically, the LLM output can be regarded as a deterministic vector, even if all its errors are concentrated in a subset of variables. In this process, each restart still independently determines whether to use an LLM value or a random value for each coordinate. The product of equation (2) is determined solely by... Decision, not demand Each error is generated by an independent random event. Compared to directly using the entire LLM assignment each time, Error coordinates are replaced with random values during partial reboots, compared to completely random initialization. And the choice of formula (5) At the same time, it retains the provable exponential gain.
[0055] (iii) Total runtime achieves resolvable exponential compression. This is obtained from formula (4). Compared to a single restart Multiplying by the upper limit of the step flip, the total time complexity of this invention is . (Excluding LLM call time). In , , Under these settings, the original Schöning takes approximately The second restart; when , , At that time, the present invention requires approximately , , Next, speed increase approximately , , Times. In , At that time, the number of restarts is approximately Compared to the original algorithm, the speedup is approximately [missing information]. Times. All the above values are in multiples of [number]. The lower bound of the statistical confidence level is used as a condition.
[0056] (iv) When LLM is unavailable or the accuracy is approximately When this happens, the algorithm automatically and smoothly reverts to the original Schöning. As can be seen from formula (5), when... Or take when the calibration results are unreliable .at this time Equations (2) and (4) strictly degenerate into the lower bound of the success probability and the upper bound of the number of restarts of the original Schöning algorithm. Therefore, even if the LLM service is unavailable in production deployment, the original algorithm guarantee can be maintained by closing the mask branch. It should be noted that if the uncalibrated... Forcibly cut off to The above does not provide this guarantee.
[0057] (v) Retaining provable analytical lower bounds facilitates worst-case budgeting in security-critical scenarios. The success probability lower bound (2) and restart count upper bound (4) of this invention are both analytical expressions, explicitly using the condition that "the actual consistency rate of the current instance is not lower than the calibration lower bound" as the applicable condition. For scenarios with explicit requirements on failure probability, such as formal verification, agent behavior constraint consistency verification, and cryptographic protocol analysis, calibration data and confidence levels can be recorded. Selected Calculated results and This is to create an auditable and reproducible budget basis. If the above conditions cannot be verified, then use... The original Schöning guarantee.
[0058] (vi) It has good scalability for general k-SAT, SMT and various statistical prior sources. The success rate formula (2) and restart count formula (4) of this invention are applicable to general k-SAT ( The form remains unchanged; only the corresponding k needs to be substituted. When a SAT instance is embedded in the SMT framework, this invention can serve as a Boolean skeleton solver layer, working in conjunction with the upper-level theoretical solver. When the prior source is replaced by a visual-language model, rule system, or other heuristic model, as long as the model can output candidate Boolean assignments and provide a verified lower bound on the pervariate consistency rate, this invention will work. Similarly, it can be calculated. and Therefore, this invention establishes a general coupling relationship of "calibrable statistical prior - random mask initialization - Schöning random walk - parsing restart budget".
[0059] A specific embodiment of the present invention discloses a logical consistency solution system based on a large language model, comprising: The prompt module is used to obtain the propositional logic satisfiability problem input by the user, convert the propositional logic satisfiability problem into a conjunctive normal form formula of satisfiability equivalence, and generate natural language prompt text based on the conjunctive normal form formula; The processing module is used to process the natural language prompt text using a large language model to obtain the Boolean assignments of each Boolean variable in the conjunctive normal form. The calculation module is used to calculate the variate consistency rate of Boolean assignments relative to the benchmark witness, and determine the mask rate and the number of restarts required to solve based on the variate consistency rate; The assignment module is used to generate a mask according to the mask ratio for each round of restart. Boolean variables marked as valid in the mask are initialized using Boolean assignment, while Boolean variables marked as invalid in the mask are initialized randomly to obtain the initial values corresponding to the current round of restart. The solution module is used to perform propositional logic satisfiability incompleteness solving based on the number of restarts and the initial assignments corresponding to each round of restarts, and to determine the satisfiable solutions of the conjunctive normal form formula.
[0060] The above-described method and system embodiments are based on the same principles, and their related aspects can be referenced from each other to achieve the same technical effects. For specific implementation processes, please refer to the foregoing embodiments, which will not be repeated here.
[0061] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for solving logical consistency based on a large language model, characterized in that, include: Obtain the propositional logic satisfiability problem input by the user, convert the propositional logic satisfiability problem into a conjunctive normal form formula of satisfiability equivalence, and generate natural language prompt text based on the conjunctive normal form formula; The natural language prompt text is processed using a large language model to obtain the Boolean assignments of each Boolean variable in the conjunctive normal form; Calculate the variate consistency rate of the Boolean assignment relative to the baseline witness, and determine the mask rate and the number of restarts required to solve based on the variate consistency rate; For each restart, a mask is generated according to the mask rate. Boolean variables marked as valid in the mask are initialized using the Boolean assignment, while Boolean variables marked as invalid in the mask are initialized randomly to obtain the initial values corresponding to this restart. Based on the number of restarts and the initial assignments corresponding to each round of restarts, the satisfiability incompleteness of the propositional logic is solved to determine the satisfiable solution of the conjunctive normal form formula.
2. The logical consistency solution method based on a large language model according to claim 1, characterized in that, Generate natural language prompt text based on the conjunctive normal form formula, including: Determine whether the original context corresponding to the conjunctive normal form formula exists; If the original context exists, a mapping table between the Boolean variable and the semantic entities in the original context is constructed using the original context. The Boolean variable is replaced and the logical relationship is transcribed using the mapping table to generate the natural language prompt text. If the original context does not exist, the Boolean variables and logical relationships are transcribed using a preset template to generate the natural language prompt text.
3. The logical consistency solution method based on a large language model according to claim 1, characterized in that, Determining the variable-wise consistency rate of the Boolean assignment relative to the benchmark witness includes: Obtain a point estimate of the variable-wise consistency rate; Calculate the statistical confidence lower bound of the point estimate and use the statistical confidence lower bound as the variable-wise consistency rate.
4. The logical consistency solution method based on a large language model according to claim 3, characterized in that, Determining the mask rate and the number of restarts required to solve based on the variable-wise consistency rate includes: Determine the data source for the point estimation; wherein the data source includes at least one of the following: statistical data of similar historical instances, features of the conjunctive normal form formula, and correlation features of the output of the large language model; When the data source is statistical data of historical similar instances, the mask ratio and the number of restarts are obtained; wherein, before the natural language prompt text is processed using a large language model, the mask ratio and the number of restarts are calculated based on the variable consistency rate; When the data source is the features of the conjunctive normal form formula and the associated features of the large language model output, the masking rate and the number of restarts are calculated based on the variable consistency rate.
5. The logical consistency solution method based on a large language model according to claim 4, characterized in that, The mask rate and the number of restarts are calculated based on the variable-wise consistency rate, including: Determine whether the interval to which the variable-wise consistency rate belongs and the calibration validity meet the preset requirements, and determine the mask rate based on the determination result; Obtain the solution control parameters, and calculate the number of restarts based on the characteristics of the variable consistency rate, the mask rate, the solution control parameters, and the conjunctive normal form formula.
6. The logical consistency solution method based on a large language model according to claim 5, characterized in that, Determining the mask rate based on the judgment result includes: When the variable-wise consistency rate is within a first preset range or the calibration validity does not meet the preset requirements, the mask rate is 0; When the variable-wise consistency rate is within a second preset range and the calibration effectiveness meets the preset requirements, the mask rate is calculated using the following formula: ; in, The mask rate, The clause length of the conjunctive normal form formula is given. Let be the variable-wise consistency rate.
7. The logical consistency solution method based on a large language model according to claim 5, characterized in that, The solution control parameters include at least a preset target failure probability; The features of the conjunctive normal form formula include at least: clause length and total number of Boolean variables; the number of restarts is calculated based on the variable-wise consistency rate, the masking rate, the solution control parameters, and the features of the conjunctive normal form formula, including: The number of restarts is calculated using the following formula: ; in, The number of restarts, The correction factor is a finite-step process, where n is the total number of Boolean variables and k is the length of the clause. The mask rate, The variable-wise consistency rate, The probability of failure of the target. , .
8. The logical consistency solution method based on a large language model according to claim 1, characterized in that, Generating a mask according to the stated mask rate includes: The mask rate is used as the global uniform mask rate, and the Bernoulli mask corresponding to each Boolean variable is generated using the global uniform mask rate; or, Using the aforementioned mask rate as the baseline mask rate, the baseline mask rate is adjusted according to the weights of each Boolean variable to obtain the independent mask rate corresponding to each Boolean variable, and Bernoulli masks are generated using the independent mask rates corresponding to each Boolean variable.
9. The logical consistency solution method based on a large language model according to claim 1, characterized in that, The initial value is: ; in, For the first The second restart Initial assignment of Boolean variables, For the first Boolean assignment of a Boolean variable, For the first The second restart Masking markers for Boolean variables, For the first The second restart Random initialization of a Boolean variable, The mask rate is denoted as .
10. A logical consistency solution system based on a large language model, characterized in that, include: The prompt module is used to obtain the propositional logic satisfiability problem input by the user, convert the propositional logic satisfiability problem into a conjunctive normal form formula of satisfiability equivalence, and generate natural language prompt text based on the conjunctive normal form formula; The processing module is used to process the natural language prompt text using a large language model to obtain the Boolean assignments of each Boolean variable in the conjunctive paradigm. The calculation module is used to calculate the variable-wise consistency rate of the Boolean assignment relative to the benchmark witness, and determine the mask rate and the number of restarts required to solve based on the variable-wise consistency rate; The assignment module is used to generate a mask according to the mask rate for each round of restart, and to perform initial assignment on Boolean variables marked as valid by the mask using the Boolean assignment, and to perform random initial assignment on Boolean variables marked as invalid by the mask, so as to obtain the initial assignment corresponding to the current round of restart. The solution module is used to perform propositional logic satisfiability incompleteness solution based on the number of restarts and the initial assignments corresponding to each round of restarts, and to determine the satisfiable solution of the conjunctive normal form formula.
