Boolean satisfiability with transitivity constraints
- 格式:pdf
- 大小:186.14 KB
- 文档页数:23
mybatis boolean 字段getter 风格MyBatis Boolean字段Getter风格在使用MyBatis进行数据库操作时,经常会遇到Boolean类型的字段。
Boolean字段表示一个逻辑值,可以是True或False。
在MyBatis中,我们有几种不同的方式来处理Boolean字段,其中之一是使用Getter方法来获取字段的值。
在本文中,我们将介绍关于使用MyBatis Boolean字段Getter风格的一些常见问题和最佳实践。
第一步:了解Boolean字段在开始之前,让我们先了解一下Boolean字段在Java中的表示。
在Java 中,Boolean类型的字段可以是原始类型(boolean)或对象类型(Boolean)。
原始类型的布尔字段定义如下:javaprivate boolean active;对象类型的布尔字段定义如下:javaprivate Boolean active;对于Boolean字段,Getter方法的命名习惯是以“is”开头,后面跟上字段名,例如:javapublic boolean isActive() {return active;}或者javapublic Boolean getActive() {return active;}第二步:设置Boolean字段的值在MyBatis中,我们可以使用Getter方法来获取Boolean字段的值。
但是,Setter方法用于设置Boolean字段的值。
对于Boolean字段的Setter 方法,我们可以按照以下命名习惯来定义:javapublic void setActive(boolean active) {this.active = active;}或者javapublic void setActive(Boolean active) {this.active = active;}第三步:配置MyBatis映射文件在使用MyBatis进行数据库操作时,我们需要定义映射文件(xml)来配置数据库表和Java对象之间的映射关系。
booleanquery 的原理
Boolean query是一种用于搜索和过滤数据的技术,它允许用户使用逻辑运算符(如AND、OR、NOT)组合多个查询条件来查找满足特定条件的数据。
例如,假设有一个包含员工信息的数据库,你可以使用Boolean query来查找特定部门(如销售部门)的特定年龄段(如30-40岁)的男性员工。
在这个例子中,你可以使用以下的Boolean query:
```
WHERE department = '销售' AND gender = '男' AND age BETWEEN 30 AND 40
```
这个Boolean query使用了逻辑运算符AND来组合三个查询条件:部门、性别和年龄。
只有当所有条件都满足时,才会返回相应的员工记录。
Boolean query的原理基于布尔代数,其中每个条件都可以被视为一个布尔变量(True 或False),而逻辑运算符则用于组合这些布尔变量以形成更复杂的条件。
在执行Boolean query时,数据库系统会评估每个条件,并将其结果组合使用逻辑运算符,以确定哪些记录满足查询条件。
Boolean query可以非常灵活地组合多个条件,以满足不同的搜索需求。
它在许多数据库系统和搜索引擎中都得到了广泛的应用。
布尔函数表示法对SAT问题求解算法的影响分析SAT(Boolean satisfiability problem)问题是计算机科学中一个经典且重要的问题,在许多领域都有广泛的应用。
SAT问题的目标是找到一个布尔赋值,使得给定的布尔函数的值为真。
为了解决这一问题,人们采用了不同的布尔函数表示法,并研究其对SAT问题求解算法的影响。
一、布尔函数表示法的定义和分类布尔函数表示法是指用一组逻辑运算符将布尔函数的逻辑关系表示出来的方法。
常见的布尔函数表示法包括合取范式(CNF)和析取范式(DNF)等。
1. 合取范式(CNF)合取范式是将布尔函数表示为若干个子句的合取,每个子句由一组文字的析取组成。
具体表示为:F = (C1 ∧ C2 ∧ ... ∧ Cn)其中,每个子句Ci由一个或多个文字的析取组成。
2. 析取范式(DNF)析取范式是将布尔函数表示为若干个子句的析取,每个子句由一组文字的合取组成。
具体表示为:F = (C1 ∨ C2 ∨ ... ∨ Cn)其中,每个子句Ci由一个或多个文字的合取组成。
二、CNF和DNF在SAT问题求解算法中的应用CNF和DNF是两种常见的布尔函数表示法,在SAT问题求解算法中起到了重要的作用。
下面将分别介绍它们对SAT问题求解算法的影响。
1. CNF对SAT问题求解算法的影响CNF表示法在SAT问题求解算法中的应用最为广泛。
CNF Formula是CNF表示法下的布尔函数,通常采用变量和逻辑运算符组成的析取式。
CNF表示法的主要优势是能够通过简单的逻辑运算实现布尔函数之间的合取和析取操作,对计算机进行编码时更加方便。
在SAT问题求解算法中,将布尔函数转化为CNF Formula后,可以应用算法对其进行求解。
例如,DPLL算法和CDCL算法等常用的SAT求解算法都是基于CNF表示法实现的。
2. DNF对SAT问题求解算法的影响与CNF相反,DNF表示法在SAT问题求解算法中的应用相对较少。
Siebel学习笔记Siebel(escript)的学习:1.Siebel的数据类型Primitive(原始的)---Number,Integer,Hexadecimal(⼗六进制),Octal(⼋进制),Floating Point(浮点),Decimal(⼗进制),Scientific(系统的),Boolean, StringComposite(复合的)---Object,Array,Special(特殊的)----Undefined(未定义的), Null,NaN(⾮数值)2. typeof ⽅法typeof variable or typeof(variable)返回值为:"undefined","boolean","string","object","number","function",or"buffer"3. Refresh Record Methods刷新Applet的记录var oBs=TheApplication().GetService("FINS Teller UI Navigation").oBs.InvokeMethod("RefreshCurrentApplet",Inputs,Outputs);/*如果input的参数中有设置Refresh All为Y,则刷新当前View所在的所有Applet*/BC有两个Method:BusComp.invokeMethod("RefreshRecord") 刷新当前记录BusComp.invokeMehtod("RefreshBusComp") 刷新当前查询记录4.TheApplication().Trace MethodTheApplication().TraceOn(filename,type,selection)Filename 为⽇志⽂件,绝对路径Type 包括Allocation和SQL1.Allocation.Traces allocations and deallocations of Siebel objects. This option is useful if you suspect memory leaks in your code.2.SQL.Traces SQL statements generated by the Siebel application.Selection ⼀般我们都⽤All就可以了eg: TheApplication().TraceOn("D:\\siebel_debug\\trace.txt","Allocation","All");5.配置MVL注意点配置MVL时需要将use primary join 打勾,不然会导致⽣成N+1条SQL语句的问题.e primary join的作⽤:use primary join没有打勾,会把每条关联数据都查询出来.use primary join 有打勾,只会把主关联数据查询出来.6.About Get BO\BCAbout Get BO1.TheApplication().ActiveBusObject();returns the business object for the business component of the active applet2.this.BusObject();returns the business object for the business component of the applet.3.TheApplication().GetBusObject("BO NAME");instantiates and returns a new instance of the argument specified business object---------------------------------------------------------------------------------------------About Get BC1.TheApplication().ActiveBusComp();returns the business component associated with the active applet.2.this.BusComp();returns the business component of the applet.Eg: this.BusComp().GetFieldValue(“Id”); //use it to get current record id3.boXXX.GetBusComp("BC NAME");instantiates and returns a new instance of the argument specified business component7.BC Operationwith(oBcName){ClearToQuery();SetViewMode(AllView);//ViewMode,⼀般常⽤的为 Organization Catelog 等ActivateField("Status");SetSearchSpec("Id", sOrdId);// or SetSearchExpr(sSearch);//特别注意 SetSearchSpec 和 SetSearchExpr 交替使⽤是会覆盖查询条件的情况,⾃⼰测试ExecuteQuery(ForwardOnly);}//DeleteRecord 不需要 NextRecord8.在 escript 中使⽤ PickList在脚本中对具有 PickList 的 Field 赋值时,不要直接使⽤ SetFieldValue 对 field 直接赋值,需要使⽤ Pick ⽅法错误的赋值⽅式:BC.SetFieldValue("fieldname", "value"),正确的赋值⽅式:with(oBcCA){var oBCPick = GetPicklistBusComp("State");with (oBCPick){ClearToQuery();SetSearchSpec("Value", "CA");ExecuteQuery(ForwardOnly);I f(FirstRecord())Pick();}//end with(oBCPick)oBCPick = null;}//end with(oBcCA)9.eScript 中 Split ⽅法的使⽤循环使⽤ Split ⽅法会引起内存泄漏,在使⽤⼀次后,请及时 destory 对象。
windowsBLE编程netwinform连接蓝⽛4.0winform 程序调⽤Windows.Devices.Bluetoot API 实现windows下BLE蓝⽛设备⾃动连接,收发数据功能。
不需要使⽤win10的UWP开发。
先贴图,回头来完善代码源码如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Windows.Devices.Bluetooth;using Windows.Devices.Bluetooth.GenericAttributeProfile;using Windows.Devices.Enumeration;using Windows.Foundation;using Windows.Security.Cryptography;namespace BLECode{public class BluetoothLECode{//存储检测的设备MAC。
public string CurrentDeviceMAC { get; set; }//存储检测到的设备。
public BluetoothLEDevice CurrentDevice { get; set; }//存储检测到的主服务。
public GattDeviceService CurrentService { get; set; }//存储检测到的写特征对象。
public GattCharacteristic CurrentWriteCharacteristic { get; set; }//存储检测到的通知特征对象。
public GattCharacteristic CurrentNotifyCharacteristic { get; set; }public string ServiceGuid { get; set; }public string WriteCharacteristicGuid { get; set; }public string NotifyCharacteristicGuid { get; set; }private const int CHARACTERISTIC_INDEX = 0;//特性通知类型通知启⽤private const GattClientCharacteristicConfigurationDescriptorValue CHARACTERISTIC_NOTIFICATION_TYPE = GattClientCharacteristicConfigurationDescriptorValue.Notify;private Boolean asyncLock = false;private DeviceWatcher deviceWatcher;//定义⼀个委托public delegate void eventRun(MsgType type, string str,byte[] data=null);//定义⼀个事件public event eventRun ValueChanged;public BluetoothLECode(string serviceGuid, string writeCharacteristicGuid, string notifyCharacteristicGuid){ServiceGuid = serviceGuid;WriteCharacteristicGuid = writeCharacteristicGuid;NotifyCharacteristicGuid = notifyCharacteristicGuid;}public void StartBleDeviceWatcher(){string[] requestedProperties = { "System.Devices.Aep.DeviceAddress", "System.Devices.Aep.IsConnected", "System.Devices.Aep.Bluetooth.Le.IsConnectable" };string aqsAllBluetoothLEDevices = "(System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\")";deviceWatcher =DeviceInformation.CreateWatcher(aqsAllBluetoothLEDevices,requestedProperties,DeviceInformationKind.AssociationEndpoint);// Register event handlers before starting the watcher.deviceWatcher.Added += DeviceWatcher_Added;deviceWatcher.Stopped += DeviceWatcher_Stopped;deviceWatcher.Start();ValueChanged(MsgType.NotifyTxt, msg);}private void DeviceWatcher_Stopped(DeviceWatcher sender, object args){string msg = "⾃动发现设备停⽌";ValueChanged(MsgType.NotifyTxt, msg);}private void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation args){ValueChanged(MsgType.NotifyTxt, "发现设备:" + args.Id);if (args.Id.EndsWith(CurrentDeviceMAC)){Matching(args.Id);}}///<summary>///按MAC地址查找系统中配对设备///</summary>///<param name="MAC"></param>public async Task SelectDevice(string MAC){CurrentDeviceMAC = MAC;CurrentDevice = null;DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelector()).Completed = async (asyncInfo, asyncStatus) => {if (asyncStatus == pleted){DeviceInformationCollection deviceInformation = asyncInfo.GetResults();foreach (DeviceInformation di in deviceInformation){await Matching(di.Id);}if (CurrentDevice == null){string msg = "没有发现设备";ValueChanged(MsgType.NotifyTxt, msg);StartBleDeviceWatcher();}}};}///<summary>///按MAC地址直接组装设备ID查找设备///</summary>///<param name="MAC"></param>///<returns></returns>public async Task SelectDeviceFromIdAsync(string MAC){CurrentDeviceMAC = MAC;CurrentDevice = null;BluetoothAdapter.GetDefaultAsync().Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == pleted){BluetoothAdapter mBluetoothAdapter = asyncInfo.GetResults();byte[] _Bytes1 = BitConverter.GetBytes(mBluetoothAdapter.BluetoothAddress);//ulong转换为byte数组Array.Reverse(_Bytes1);string macAddress = BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToLower();string Id = "BluetoothLE#BluetoothLE" + macAddress + "-" + MAC;await Matching(Id);}};}private async Task Matching(string Id){try{BluetoothLEDevice.FromIdAsync(Id).Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == pleted){BluetoothLEDevice bleDevice = asyncInfo.GetResults();//在当前设备变量中保存检测到的设备。
布尔可满足性问题的启发式求解算法引言布尔可满足性问题(Boolean Satisfiability Problem,简称SAT)是计算机科学中一个经典的问题。
给定一个布尔表达式,判断是否存在一组变量的赋值,使得该表达式为真。
SAT问题是一个NP完全问题,通常在实际应用中遇到大规模的情况下,求解时间较长。
为了加快求解速度,并找到最优解,研究人员发展了各种启发式求解算法。
本文将介绍一些常用的启发式求解算法。
1. 真值传播算法真值传播算法是一种广泛应用于SAT问题求解的启发式算法。
该算法利用逻辑公式的传播规则,对变量的真值进行推理,以便找到更多的可满足解。
算法的核心思想是根据已有的真值分配,推断出其他变量可能的取值,为下一步的决策提供参考。
2. 单子句传播算法单子句传播算法是真值传播算法的一种变体。
它通过从公式中抽取出单子句,将其直接赋值为真,从而简化了问题的形式,并约束了其他变量的取值范围。
这一过程可以减少搜索空间,加速求解过程。
3. 学习策略学习策略在SAT问题中起到了关键作用。
当求解算法在搜索过程中遇到冲突时,学习策略能够根据已有信息获得新的限制条件,提高求解效率。
一种常用的学习策略是学习子句的单位分辨,即从冲突子句中选择一个文字,反转它的取值,得到一个新子句,并添加到公式中。
这样可以避免再次遇到类似的冲突。
4. 启发式变量选择选择合适的变量进行赋值是求解SAT问题时的一个重要决策。
启发式变量选择策略可以根据一些指标,如出现频率、相互影响等,选取具有较高影响力的变量。
这样可以更快地找到满足条件的解。
5. 分支策略分支策略是SAT求解算法中的一项关键技术。
它根据已有的真值分配,选择一个变量进行赋值。
一般来说,该变量应该是具有较大的决策影响的变量。
分支策略的选择对求解效率有重要影响,需要根据问题的性质进行灵活调整。
结论布尔可满足性问题是一个经典而重要的问题,在许多实际应用中都有广泛的应用。
为了提高求解效率,研究人员提出了各种启发式求解算法。
数据结构-最⼤堆、最⼩堆【⼿动实现】0,堆的简介 数据结构中的堆是⼀种特殊的⼆叉树,不同于 Java 内存模型中的堆。
堆必须符合以下两个条件:1. 是⼀棵完全⼆叉树。
2. 任意⼀个节点的值都⼤于(或⼩于)左右⼦节点的值。
从第⼀点可以知道,堆适合⽤数组来存储。
第⼆点中,若⽗节点都⼤于等于左右⼦节点,则被称为⼤顶堆,反之则为⼩顶堆。
图-最⼤堆及其存储⽅式 0.1节点的⽗、⼦节点关系 ⼀个节点【根节点除外】的⽗节点地址为其地址的⼆分之⼀,它的左⼦节点地址为其地址值的2倍,右⼦节点地址为其地址2倍加1。
例如:现在有个节点的地址为3,其数值为5;那么它的⽗节点地址为3/2=1,⽗节点的数值为13;左⼦节点地址为3*2=6,左⼦节点数值为6;右⼦节点地址为3*2+1=7,这个最⼤堆中没有其右节点数据。
0.2节点的存储、删除操作 添加新元素的时候,⼀般先存放到数组的尾部,之后在通过向上重排序的操作,来进⾏堆化【满⾜堆数据结构的调整】 删除元素时【⼀般默认删除第⼀个根节点】,现将数组的最后⼀个元素放到根节点的位置,之后通过向下重排序的操作,来进⾏堆化处理。
1,堆的实现 主要实现功能:①添加元素-add();②输出极值并清除-poll();③输出极值不清除-peek(); 上⾯的功能都是是显⽰的函数,隐形函数有:①扩容dilatate();②向上重排序reSortUp();③向下重排序reSortDown();package blogs.mufasa.Solution1;public class Heap {private static final int CAPACITY=16;private static final boolean TYPE=true;private static int[] nums;private int capacity=16;int size=0;private boolean type=true;//true由⼩到⼤,false由⼤到⼩public Heap(){this(CAPACITY);}public Heap(int capacity){this(capacity,TYPE);}public Heap(boolean type){this(CAPACITY,type);}public Heap(int capacity,boolean type){this.capacity=capacity;this.type=type;nums=new int[capacity];}//数据添加public void add(int num){if(size+1>=capacity){dilatate();}nums[size+1]=num;reSortUp(size+1);size++;}private void reSortUp(int index){if(type){//由⼩到⼤while (index!=1){if(nums[index/2]>nums[index]){int temp=nums[index];nums[index]=nums[index/2];nums[index/2]=temp;index/=2;}else if(nums[index/2]==nums[index]){// throw new IllegalArgumentException("数据结构-堆不接受重复数据输⼊");break;}else {return;}}}else {//由⼤到⼩while (index!=1){if(nums[index/2]<nums[index]){int temp=nums[index];nums[index]=nums[index/2];nums[index/2]=temp;index/=2;}else if(nums[index/2]==nums[index]){// throw new IllegalArgumentException("数据结构-堆不接受重复数据输⼊");break;}else {return;}}}}//数据输出,并且清楚该数据public int poll() throws Exception {if(size>0){int temp=nums[1];nums[1]=nums[size];reSortDown();size--;return temp;}else {throw new Exception("数据为空");}}private void reSortDown(){int index=1;int L,R;if(type){//由⼩到⼤while (index<size){L=index*2;R=L+1;if(R<=size){boolean flag=nums[L]<nums[R];int min=(flag?nums[L]:nums[R]);if(nums[index]>min){if(flag){int temp=nums[index];nums[index]=nums[L];nums[L]=temp;index=L;}else {int temp=nums[index];nums[index]=nums[R];nums[R]=temp;index=R;}}else {return;}}else if(L<=size){if(nums[index]>nums[L]){int temp=nums[index];nums[index]=nums[L];nums[L]=temp;}return;}else {return;}}}else {//由⼤到⼩while (index<size){L=index*2;R=L+1;if(R<size){boolean flag=nums[L]<nums[R];int max=(flag?nums[R]:nums[L]);if(nums[index]<max){if(flag){int temp=nums[index];nums[index]=nums[R];nums[R]=temp;index=R;}else {int temp=nums[index];nums[index]=nums[L];nums[L]=temp;index=L;}}else {return;}}else if(L<size){if(nums[index]<nums[L]){int temp=nums[index];nums[index]=nums[L];nums[L]=temp;}return;}else {return;}}}}//数据输出,不清除该数据public int peek() throws Exception {if(size>0){return nums[0];}else {throw new Exception("数据为空");}}//数据扩容,⼆倍扩容private void dilatate(){capacity=capacity<<1;int[] pre=new int[capacity];for(int i=1;i<=size;i++){pre[i]=nums[i];}nums=pre;}}class Client{public static void main(String[] args) throws Exception { Heap heap=new Heap(4,true);// Heap heap=new Heap(4,false);heap.add(5);heap.add(3);heap.add(3);heap.add(7);heap.add(1);heap.add(0);heap.add(8);heap.add(8);int len=heap.size;for(int i=0;i<len;i++){System.out.print(heap.poll()+",");}}}/*0,1,3,5,7,8,8,7,5,3,1,0,*/2,堆的应⽤ 3.1 堆排序 利⽤堆这种数据结构,来进⾏数组排序,时间复杂度为O(nlogn) 3.2 Java容器中的优先队列 PriorityQueue<Integer> queue=new PriorityQueue<Integer>(); 3.3 求动态集合中位数 有若⼲个数据,求其中位数,并且数据还在不断的输⼊【两个堆数据即可很好的解决问题,⼀个最⼤堆,⼀个最⼩堆】 3.4 60百分位的数 这个问题是上⾯的问题的扩展,本质上也是使⽤两个对数据结构即可。
[信息检索]第⼀讲布尔检索BooleanRetrieval第⼀讲布尔检索Boolean Retrieval主要内容:1. 信息检索概述2. 倒排记录表3. 布尔查询处理⼀、信息检索概述什么是信息检索?Information Retrieval (IR) is finding material (usually documents) of an unstructured nature (usually text) that satisfies an information need from within large collections (usually stored on computers).信息检索是从⼤规模⾮结构化数据(通常是⽂本)的集合(通常保存在计算机上)中找出满⾜⽤户信息需求的资料(通常是⽂档)的过程。
Document –⽂档Unstructured – ⾮结构化Information need –信息需求Collection—⽂档集、语料库⼆、倒排记录表1、什么是布尔查询?布尔查询是指利⽤ AND, OR 或者 NOT操作符将词项连接起来的查询如:信息 AND 检索2、⼀个信息检索的例⼦(莎⼠⽐亚全集)不到100万单词,假设每个英⽂单词平均长度为8字节,则整个全集不到10MB查询需求:莎⼠⽐亚的哪部剧本包含Brutus及Caesar但是不包含Calpurnia?查询的布尔表⽰:Brutus AND Caesar AND NOT Calpurnia解决⽅案:⽅法⼀:暴⼒⽅法从头到尾扫描所有剧本,对每部剧本判断它是否包含Brutus AND Caesar ,同时⼜不包含Calpurnia不⾜之处:速度超慢 (特别是⼤型⽂档集)处理NOT Calpurnia 并不容易(不到末尾不能停⽌判断)不太容易⽀持其他操作 (e.g., 寻找靠近countrymen的单词Romans)不⽀持检索结果的(灵活)排序 (排序时只返回较好的结果)优点:实现简单很容易⽀持⽂档动态变化⽅法⼆:倒排记录表词项-⽂档(term-doc)关联矩阵若某剧本包含某单词,则该位置为1,否则为0.关联矩阵的每⼀列(对应⼀篇⽂档)都是 0/1向量,每个0/1都对应⼀个词项关联矩阵的每⼀⾏(对应⼀个词项)也可以看成⼀个0/1向量,每个0/1代表该词项在相应⽂档中的出现与否给定查询Brutus AND Caesar AND NOT Calpurnia取出三个词项对应的⾏向量,并对Calpurnia 的⾏向量求反,最后按位进⾏与操作110100 AND 110111 AND 101111 = 100100.问题:当出现更⼤的⽂档集假定N = 1 百万篇⽂档(1M), 每篇有1000个词(1K)假定每个词平均有6个字节(包括空格和标点符号),那么所有⽂档将约占6GB 空间.假定词汇表的⼤⼩(即词项个数) M = 500K此时,词项-⽂档矩阵将⾮常⼤矩阵⼤⼩为 500K x 1M=500G但是该矩阵中最多有10亿(1G)个1:词项-⽂档矩阵⾼度稀疏(sparse)更好的办法:仅仅记录1的位置,即倒排索引对每个词项t, 记录所有包含t的⽂档列表.每篇⽂档⽤⼀个唯⼀的 docID来表⽰,通常是正整数,如1,2,3…磁盘上,顺序存储⽅式⽐较好,便于快速读取内存中,采⽤链表或者可变长数组⽅式倒排记录表按docID排序索引构建过程:1、词条序列:<词条,docID>⼆元组2、排序按词项排序,然后每个词项按docID排序1. 词典&倒排记录表某个词项在单篇⽂档中的多次出现会被合并拆分成词典和倒排记录表两部分每个词项出现的⽂档数⽬(doc frequency, DF)会被加⼊3、布尔查询的处理假定索引已经构建好了,如何利⽤索引来处理查询?AND查询的处理:考虑如下查询(从简单的布尔表达式⼊⼿):Brutus AND Caesar在词典中定位 Brutus返回对应倒排记录表(对应的docID)在词典中定位Caesar再返回对应倒排记录表合并(Merge)两个倒排记录表,即求交集合并过程:每个倒排记录表都有⼀个定位指针,两个指针同时从前往后扫描, 每次⽐较当前指针对应倒排记录,然后移动某个或两个指针。
分享两篇SCI发表的经历三年前对于我来说SCI就是天书一样,在我踏进博士的门槛后我以为自己进入了地狱,也纠结也彷徨,整天刷虫友们对于博士、SCI的帖子,我选择了虫友们鼓励的那一部分来激励自己继续前行。
我告诉自己坚持就是胜利,当然那是积极的坚持。
在好几月之前就有这个想法,今天早上收到第二篇的接收通知后,我便想今天一定要在小木虫上谢谢那些给予我帮助的虫友们。
话不多说,我把自己这两篇投稿的经历与大家共享,希望能给大家带来一点点用处。
第一篇发表在FitoterapiaCover letterDear Editor Verotta:We would like to submit the manuscript entitled "××××××题目" by ××××××所有作者姓名which we wish to be considered for publication in Journal of Fitoterapia.All authors have read and approved this version of the article, and due care has been taken to ensure the integrity of the work. Neither the entire paper nor any part of its content has been published or has been accepted elsewhere. It is not being submitted to any other journal.We believe the paper may be of particular interest to the readers of your journal as it is the first time of ××××××研究的精华所在Thank you very much for your reconsidering our revised manuscript for potential publication in Fitoterapia. We are looking forward to hearing from you soon. Correspondence should be addressed to Jinhui Yu at the following address, phone and fax number, and email address.地址、学院、学校名称Phone: + 86××××××Fax number: + 86571××××××Best wishes for you and your family!Sincerely yours,×××所有作者Response to reviewersDear Editor:Thank you very much for your letter and the comments from the referees about our paper submitted to Journal of Fitoterapia (FITOTE-D-11-01071). The manuscript entitled "××××××" by ××××××所有作者have been revised according to the reviewers’ comments, and we wish it to be reconsidered for publication in Journal of Fitoterapia.A list of changes and responses to reviewers are as follows.List of ActionsLOA1: The key words were changed in page?.LOA2: The name and location of the local biochemistry company have been added in section 2.1 (page 3).LOA3: A paragraph has been added in section 3.1 (page 5) to further explain the determination of the cis and trans configuration of double bonds in polyprenols.LOA4: The language was improved by English language editing of Elsevier webshop.To Reviewer 1#,Thank you very much for pointing out the problems in our manuscript. We have revised it according to your recommendations. We would like to know if there are still somewhere need to be amended.(1) Keywords: general terms should be avoided; I would change some of the keywords (homologues, identification, quantification)The key words have been changed as follows: ××××××修改后关键词(2) In paragraph 2.1 the "local biochemistry company" should be identified byname and location.The name and location of the local biochemistry company have been added in section 2.1 (page 3). NaOH,Pyrogallol,anhydrous Na2SO4 were purchased from Hangzhou ChangqingHuagong CO., LTD.(3) How the cis and trans configuration of double bonds in ××××××were determined? Authors should say something about.The following paragraph has been added in section 3.1 (page 5) to further explain the determination of the cis and trans configuration of double bonds in ××××××.(4) Language should be checked for clarity and correctness.The language was improved by English language editing of Elsevier webshop.To Reviewer 2#,Thank you very much for your recommendation on our paper and we have improved by English language editing of Elsevier webshop.All in all, thank you very much for your reconsidering our revised manuscript for potential publication in Fitoterapia. I'm looking forward to hearing from you soon. Correspondence should be addressed to ****第一作者或通讯作者at the following address, phone and fax number, and email address.地址Phone: + 86571××××××Fax number: + ××××××Best wishes for you and your family!Sincerely yours,××××××所有作者总的来说,第一篇文章没有费很大劲。
信息技术----服务管理--- Part1: 服务管理体系要求ISO/IEC 20000-1Second edition2011-04-15INTERNATIONALSTANDARD Reference numberISO/IEC 20000-1:2011(E)ISO/IEC 20000-1:2011 (中英文对照版) 版本:V1.0 前言Foreword (6)介绍Introduction (8)1范围Scope (11)1.1总则General (11)1.2应用Application (11)2引用标准Normative references (13)3术语和定义Terms and definitions (13)4服务管理体系总要求Service management system general requirements (18)4.1管理职责Management responsibility (18)4.1.1管理承诺Management commitment (18)4.1.2服务管理政策Service management policy (18)4.1.3权利、职责和沟通Authority, responsibility and communication (18)4.1.4管理者代表Management representative (18)4.2对其他相关方所运营过程的管控Governance of processes operated by other parties (18)4.3文件管理Documentation management (19)4.3.1建立和维护文件Establish and maintain documents (19)4.3.2文件的控制Control of documents (19)4.3.3记录的控制Control of records (20)4.4资源管理Resource management (20)4.4.1资源的提供Provision of resources (20)4.4.2人力资源Human resources (20)4.5建立和改进SMS Establish and improve the SMS (20)ISO/IEC 20000-1:2011 (中英文对照版) 版本:V1.04.5.1定义范围Define scope (20)4.5.2规划SMS Plan the SMS(Plan) (21)4.5.3实施和执行SMS Implement and operate the SMS(D O) (21)4.5.4监控和回顾SMS Monitor and review the SMS(Check) (22)4.5.4.1总要求General (22)4.5.4.2内部审核Internal audit (22)4.5.4.3管理评审Management review (22)4.5.5维护和改进SMS Maintain and improve the SMS(A CT) (23)4.5.5.1总要求General (23)4.5.5.2管理改进Management of improvements (23)5设计并转换新的或变更的服务Design and transition of new or changed services (24)5.1总要求General (24)5.2规划新的或变更的服务Plan new or changed services (24)5.3设计和开发新的或变更的服务Design and development of new or changed services (25)5.4新的或变更的服务的转换Transition of new or changed services (26)6服务交付过程Service delivery processes (26)6.1服务级别管理Service level management (26)6.2服务报告Service reporting (26)6.3服务连续性和可用性管理Service continuity and availability management (27)6.3.1服务连续性和可用性需求Service continuity and availability requirements .. 276.3.2服务连续性和可用性计划Service continuity and availability plans (27)6.3.3服务连续性和可用性的监控与测试Service continuity and availabilityISO/IEC 20000-1:2011 (中英文对照版) 版本:V1.0 monitoring and testing (28)6.4服务的预算与核算Budgeting and accounting for services (28)6.5容量管理Capacity management (29)6.6信息安全管理Information security management (29)6.6.1信息安全方针Information security policy (29)6.6.2信息安全控制Information security controls (29)6.6.3信息安全的变更和事件Information security changes and incidents (30)7关系过程Relationship process (30)7.1业务关系管理Business relationship management (30)7.2供应商管理Supplier management (31)8解决过程Resolution processes (32)8.1事件和服务请求管理Incident and service request management (32)8.2问题管理Problem management (33)9控制过程Control processes (34)9.1配置管理Configuration management (34)9.2变更管理Change management (35)9.3发布与部署管理Release and deployment management (36)ISO/IEC 20000-1:2011 (中英文对照版) 版本:V1.01即将出版(对ISO/IEC20000-2的技术修订)。
JAVA复习资料第一章1.Given the following,1. interface Base {2. boolean m1 ();3. byte m2(short s);4. }Which code fragments willcompile?(Choose all that apply.)A.interface Base2 implements Base { }B.abstract class Class2 extends Base { publicboolean ml() { return true; } }C.abstract class Class2 implements Base { }D.abstract class Class2. implements Base{ public boolean m1() { return (true); } }E.class Class2 implements Base { booleanm1( ) { return false; } byte m2(short s){ return 42; } }2. Which declare a compilable abstract class? (Choose all that apply.)A.public abstract class Canine { public Barkspeak(); }B.public abstract class Canine { public Barkspeak() { } }C.public class Canine { public abstract Barkspeak(); }D.public class Canine abstract{ publicabstract Bark speak(); }3. Which is true? (Choose all that apply. )A."X extends Y" is correct if and only if X isa class and Y is an interface.B."X extends Y" is correct if and only if X isan interface and Y is a class.C."X extends Y" is correct if X and Y areeither both classes or both interfaces.D."X extends Y" is correct for allcombinations of X and Y being classesand/or interfaces.4. Which are valid declarations? (Choose all that apply.)A.int $x;B.int 123;C.int _123;D.int #dim;E.int %percent;F.int *divide;G.intcentral_sales_region_Summer_2005_gross_sales第二章1. Which statement(s) are true? (Choose all that apply.)A.Has-a relationships always rely oninheritance.B.Has-a relationships always rely on instance variables.C.Has-a relationships always require at leasttwo class types.D.Has-a relationships always rely on polymorphism.E.Has-a relationships are always tightlycoupled.2.Given:class Clidders {public final void flipper(){ System.out.println("Clidder"); }}public class Clidlets extends Clidders {public void flipper() {System.out.println("Flip a Clidlet");super.flipper();}public static void main(String [] args) {new Clidlets().flipper();}}What is the result?A.Flip a ClidletB.Flip a ClidderC.Flip a ClidderFlip a ClidletD.Flip a ClidletFlip a ClidderE.Compilation fails.3. Given:public abstract interface Frobnicate { public void twiddle(String s) ; }Which is a correct class? (Choose all that apply.)A.public abstract class Frob implementsFrobnicate {public abstract void twiddle(String s){}}B.public abstract class Frob implementsFrobnicate { }C.public class Frob extends Frobnicate {public void twiddle(Integer i) { }}D.public class Frob implements Frobnicate {public void twiddle(Integer i) { }}E.public class Frob implements Frobnicate {public void twiddle(String i) { }public void twiddle(Integer s) { }}4. Given: class Top {public Top(String s) { System.out.print("B"); } }public class Bottom2 extends Top {public Bottom2(String s){ System.out.print("D"); }public static void main(String [] args) {new Bottom2("C");System.out.println(" ");}}What is the result?A.BDB.DBC.BDCD.DBC/doc/225135914.html,pilation fails.5. Select the two statements that best indicate a situation with low coupling. (Choose two.)A.The attributes of the class are all private.B.The class refers to a small number of otherobjects.C.The object contains only a small number of variables.D.The object is referred to using ananonymous variable, not directly.E.The reference variable is declared for aninterface type, not a class. The interfaceprovides a small number of methods.F.It is unlikely that changes made to oneclass will require any changes in another.6. Given:class Clidder {private final void flipper() { System.out.println ("Clidder"); } }public class Clidlet extends Clidder {public final void flipper(){ System.out.println("Clidlet"); }public static void main(String [] args) {new Clidlet().flipper();}}What is the result?A.ClidletB.ClidderC.ClidderClidletD.ClidletClidder/doc/225135914.html,pilation fails.7. Using the fragments below, complete the following codeso it compiles. Note, you may not have to fill all of the slots.Code:class AgedP {__________ _________ __________________ _________public AgedP(int x) {_ ________ _ ________ _ _________________ ___________}}public class Kinder extends AgedP {_________ _________ __________________ _________ _________public Kinder(int x) {_________ _________ __________________ ___________() ;}}Fragments: Use the following fragments zero or more times: AgedP super this( ) { }; 8. Given:1. class Plant {2. String getName() { return "plant"; }3. Plant getType() { return this; }4. }5. class Flower extends Plant {6. // insert code here7. }8. class Tulip extends Flower {}Which statement(s), inserted at line 6, will compile? (Choose all that apply.)A.Flower getType() { return this; }B.String getType() { return "this"; }C.Plant getType() { return this; }D.Tulip getType() { return new Tulip() ;}9. Given:1. class Zing {2. protected Hmpf h;3. }4. class Woop extends Zing { }5. class Hmpf { }Which is true? (Choose all that apply.)A.Woop is-a Hmpf and has-a zing.B.zing is-a Woop and has-a Hmpf.C.Hmpf has-a Woop and Woop is-a Zing.D.Woop has-a Hmpf and Woop is-a zing.E.Zing has-a Hmpf and Zing is-a Woop.10. Given:1. class Programmer {2. Programmer debug() { return this; }3. }4. class SCJP extends Programmer {5. // insert code here6. }Which, inserted at line 5, will compile? (Choose all that apply.)A.Programmer debug() { return this; }B.SCJP debug() { return this; }C.Object debug() { return this; }D.int debug() { return 1; }E.int debug(int x) { return 1; }F.Object debug (int x) { return this; }第四章1. Given:class Hexy {public static void main(String[] args) {Integer i = 42;String s =(i<40)?"life":(i>50)?"universe":"everything";System.out.println(s);}}What is the result?A.nullB.lifeC.universeD.everything/doc/225135914.html,pilation fails.F.An exception is thrown at runtime.2. Given:1. class Example {2. public static void main(String[] args) {3. Short s = 15;4. Boolean b;5. // insert code here6. }7. }Which, inserted independently at line 5, will compile? (Choose all that apply.)A. b = (Number instanceof s);B. b = (s instanceof Short);C. b = s.instanceof(Short);D. b = (s instanceof Number);E. b = s.instanceof(Object);F. b = (s instanceof String);3. Given:1. class Comp2 {2. public static void main(String[] args) {3. float f1 = 2.3f;4. float[][] f2 = {{42.Of}, {l.7f, 2.3f}, {2.6f, 2.7f}};5. float[] f3 = {2.7f};6. Long x = 42L;7. // insert code here8. System.out.println("true");9. }10. }And the following five code fragments:F1. if (f1 == f2)F2.if (f1 == f2[2][1])F3. if (x == f2[0][0])F4. if (f1 == f2 [1,1] )F5. if (f3 == f2 [2] )What is true?A.One of them will compile, only one will be true.B.Two of them will compile, only one willbe true.C.Two of them will compile, two will be true.D.Three of them will compile, only one willbe true.E.Three of them will compile, exactly twowill be true.F.Three of them will compile, exactly threewill be true.4. Given:class Fork {public static void main(String[] args) {if(args.length == 1 | args[1] .equals("test")) { System.out.println ("test case");} else {System.out.println("production " +args[0]) ;}}}And the command-line invocation:java Fork live2What is the result?A.test caseB.productionC.test case live2/doc/225135914.html,pilation fails.E.An exception is thrown at runtime.5. Given:class Foozit {public static void main(String[] args) {Integer x = 0;Integer y = 0;for(Short z = 0; z < 5; z++)if((++x > 2) || (++y > 2))X++ ;System.out.println (x + " " + y);}}What is the result?A. 5 1B. 5 2C. 5 3D.8 1E.8 2F.8 3G.10 2H.10 3第六章4. Given:Class TKO {public static void main(String[] args) {String s = "-";Integer x = 343;long L343 = 343L;if(x.equals(L343)) s += ".e1 ";if(x.equals(343)) s += ".e2 ";Short s1 = (short)((new Short((short)343)) / (new Short((short)49)));if (s1 == 7) s += "=s ";if(sl < new Integer(7+1)) s += "fly ";System.out.println(s);}}Which of the following will be included in the output String s? (Choose all that apply.)A..e1B..e2C.=sD.flyE.None of the above./doc/225135914.html,pilation fails.G.An exception is thrown at runtime.5. Given:1. import java.text.*;2. class DateOne {3. public static void main(String[] args) {4. Date d = new Date(1123631685981L);5. DateFormat df = new DateFormat();6. System.out.println(df.format(d));7. }8. }And given that 1123631685981L is the number of milliseconds between Jan. 1, 1970, and sometime on Aug. 9, 2005, what is the result? (Note: the time of day in option A may vary.)A.8/9/05 5:54 PMB.1123631685981L,C.An exception is thrown at runtime./doc/225135914.html,pilation fails due to a single error inthe code./doc/225135914.html,pilation fails due to multiple errors inthe code.6. Given:import java.io.*;class Keyboard { }public class Computer implements Serializable {private Keyboard k = new Keyboard(); public static void main(String[] args)Computer c = new Computer();c.storeIt(c) ;}void storeIt(Computer c) {try {ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("myFile"));os.writeObject(c);os.close() ;System.out.println("done");} catch (Exception x){System.out.println("exc"); } }}}What is the result? (Choose all that apply.)A.excB.done/doc/225135914.html,pilation fails.D.Exactly one object is serialized.E.Exactly two objects are serialized.7. Using the fewest fragments possible (and filling the fewest slots possible), complete the code below so that the class builds a directory named "dir3" and creates a file named "file3" inside "dir3". Note you can use each fragment either zero or one times.import java.io.________________class Maker {public static void main(String [] args) {___________ _________________________________ _________________________________ _________________________________ _________________________________ _________________________________ _________________________________ ______________________}}Fragments:File; FileDescriptor; FileWriter; Directory; try { .createNewDir(); File dirFile{ } (Exception x) ("dir3");filefile .createNewFile(); = new File = new File dir (dir, "file3"); (dir,file); .createFile() ;} catch ("dir3", "file3"); .mkdir(); File file1. Given:import java.util.*;class Test {public static void main(String[] args) {// insert code herex.add("one");x.add("two");x. add ("TWO");System.out.printIn(x.poll());}}Which, inserted at // insert code here, will compile? (Choose all that apply.)A.List x = newLinkedList();B.TreeSet x = newTreeSet();C.HashSet x = newHashSet();D.Queue x = newPriorityQueue();E.ArrayList x = newArrayList();F.LinkedList x = newLinkedList();2. Given:public static void main(String[] args) {// INSERT DECLARATION HEREfor (int i = 0; i <= 10; i++) {List row = newArrayList();for (int j = 0; j <= 10; j++)row.add(i * j);table.add(row);}for (List row : table)System.out.println(row);}Which statements could be inserted at // INSERT DECLARATION HERE to allow this code to compile and run? (Choose all that apply.)A.List<list> table = new</listList<list>();</listB.List<list> table = new</listArrayList<list>();</listC.List<list> table = new</listArrayList<arraylist>();</arraylistD.List table = new List<list,< p="">Integer>();E.List table = newArrayList();F.List table = newArrayList();G.None of the above.3. Which statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose all that apply.)A.If the equals() method returns true, thehashCode() comparison == might returnfalse.B.If the equals() method returns false, the hashCode() comparison == might returntrue.C.If the hashCode() comparison == returnstrue, the equals() method must return true.D.If the hashCode() comparison == returnstrue, the equals() method might return true.E.If the hashCode() comparison ! = returnstrue, the equals() method might return true.15. Given:12. TreeSet map = new TreeSet();13. map.add("one");14. map.add("two");15. map.add("three");16. map.add("four"};17. map.add("one");18. Iterator it = map.iterator();19. while (it.hasNext() ) {20. System.out.print( it.next() + " " );21. }What is the result?/doc/225135914.html,pilation fails.B.one two three fourC.four three two oneD.four one three twoE.one two three four oneF.one four three two oneG.An exception is thrown at runtime.H.The print order is not guaranteed.16. Given a method declared as:public static List process(List nums)A programmer wants to use this method like this: // INSERT DECLARATIONS HEREoutput = process(input);Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.)A.ArrayList input = null;ArrayList output = null;B.ArrayList input = null;List output = null;C.ArrayList input = null;List output = null;D.List input = null;ArrayList output = null;E.List input = null;List output = null;F.List input = null;List output = null;G.None of the above.第九章1. Given:public class Messager implements Runnable { public static void main(String[] args) {new Thread(newMessager("Wallace")).start() ;new Thread(newMessager("Gromit")).start();}private String name;public Messager(String name) { /doc/225135914.html, = name; }public void run() {message(1);message(2);}private synchronized void message(int n) {System.out.print(name + "-" + n + " ");} }Which of the following is a possible result? (Choose all that apply.)A.Wallace-1 Wallace-2 Gromit-1B.Wallace-1 Gromit-2 Wallace-2 Gromit-1C.Wallace-1 Gromit-1 Gromit-2 Wallace-2D.Gromit-1 Gromit-2E.Gromit-2 Wallace-1 Gromit-1 Wallace-2F.The code does not compile.G.An error occurs at run time.2. Given:public class Letters extends Thread {private String name;public Letters(String name) {/doc/225135914.html, = name;}public void write () {System.out.print(name);System.out.print(name);}public static void main(String[] args) {new Letters("X").start();new Letters("Y").start();}}We want to guarantee that the output can be either XXYY or YYXX, but never XYXY or any other combination. Which of the following method definitions could be added to the Letters class to make this guarantee? (Choose all that apply.)A.public void run() { write(); }B.public synchronized void run() { write(); }C.public static synchronized void run(){ write(); }D.public void run() { synchronized(this){ write(); } }E.public void run(){ synchronized(Letters.class) { write(); } }F.public void run () { synchronized(System.out) { write (); } }G.public void run(){ synchronized(System.out.class){ write(); } }3. The following block of code creates a Thread using a Runnable target:Runnable target = new MyRunnable();Thread myThread = new Thread(target);Which of the following classes can be used to create the target, so that the preceding code compiles correctly?A.public class MyRunnable extendsRunnable{public void run(){}}B.public class MyRunnable extendsObject{public void run(){}}C.public class MyRunnable implements Runnable{public void run(){}}D.public class MyRunnable implements Runnable{void run(){}}E.public class MyRunnable implements Runnable{public void start(){}}4. Given:2. class MyThread extends Thread {3. public static void main(String [] args) {4. MyThread t = new MyThread();5. t.start() ;6. System.out.print("one. ");7. t.start();8. System.out.print("two. ");9. }10. public void run() {11. System.out.print("Thread "};12. }13. }What is the result of this code?/doc/225135914.html,pilation fails.B.An exception occurs at runtime.C.Thread one. Thread two.D.The output cannot be determined.5. Given:3. class MyThread extends Thread {4. public static void main(String [] args) {5. MyThread t = new MyThread () ;6. Thread x = new Thread(t);7. x.start();8. }9. public void run() {10. for(int i=0;i<3;++i) {11. System.out.print(i + "..");12. }13. }14. }What is the result of this code?/doc/225135914.html,pilation fails.B.1‥2‥3‥C.0‥1‥2‥3‥D.0‥1‥2‥E.An exception occurs at runtime.</list,<>。
重写hashCode()和equals()⽅法详细介绍⽬录如何重写equals()⽅法如何重写hashCode()⽅法重写equals()⽽不重写hashCode()的风险总结hashCode()和equals()⽅法可以说是Java完全⾯向对象的⼀⼤特⾊.它为我们的编程提供便利的同时也带来了很多危险.这篇⽂章我们就讨论⼀下如何正解理解和使⽤这2个⽅法.如何重写equals()⽅法如果你决定要重写equals()⽅法,那么你⼀定要明确这么做所带来的风险,并确保⾃⼰能写出⼀个健壮的equals()⽅法.⼀定要注意的⼀点是,在重写equals()后,⼀定要重写hashCode()⽅法.具体原因稍候再进⾏说明.我们先看看 JavaSE 7 Specification中对equals()⽅法的说明:·It is reflexive: for any non-null reference value x, x.equals(x) should return true.·It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.·It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.·It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.·For any non-null reference value x, x.equals(null) should return false.这段话⽤了很多离散数学中的术数.简单说明⼀下:1. ⾃反性:A.equals(A)要返回true.2. 对称性:如果A.equals(B)返回true, 则B.equals(A)也要返回true.3. 传递性:如果A.equals(B)为true, B.equals(C)为true, 则A.equals(C)也要为true. 说⽩了就是 A = B , B = C , 那么A = C.4. ⼀致性:只要A,B对象的状态没有改变,A.equals(B)必须始终返回true.5. A.equals(null) 要返回false.相信只要不是专业研究数学的⼈,都对上⾯的东西不来电.在实际应⽤中我们只需要按照⼀定的步骤重写equals()⽅法就可以了.为了说明⽅便,我们先定义⼀个程序员类(Coder):class Coder {private String name;private int age;// getters and setters}我们想要的是,如果2个程序员对象的name和age都是相同的,那么我们就认为这两个程序员是⼀个⼈.这时候我们就要重写其equals()⽅法.因为默认的equals()实际是判断两个引⽤是否指向内在中的同⼀个对象,相当于 == . 重写时要遵循以下三步:1. 判断是否等于⾃⾝.if(other == this)return true;2. 使⽤instanceof运算符判断 other 是否为Coder类型的对象.if(!(other instanceof Coder))return false;3. ⽐较Coder类中你⾃定义的数据域,name和age,⼀个都不能少.Coder o = (Coder)other;return .equals(name) && o.age == age;看到这有⼈可能会问,第3步中有⼀个强制转换,如果有⼈将⼀个Integer类的对象传到了这个equals中,那么会不会扔ClassCastException呢?这个担⼼其实是多余的.因为我们在第⼆步中已经进⾏了instanceof 的判断,如果other是⾮Coder对象,甚⾄other是个null, 那么在这⼀步中都会直接返回false, 从⽽后⾯的代码得不到执⾏的机会.上⾯的三步也是<Effective Java>中推荐的步骤,基本可保证万⽆⼀失.如何重写hashCode()⽅法在JavaSE 7 Specification中指出,"Note that it is generally necessary to override the hashCode method whenever this method(equals) is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes."如果你重写了equals()⽅法,那么⼀定要记得重写hashCode()⽅法.我们在⼤学计算机数据结构课程中都已经学过哈希表(hash table)了,hashCode()⽅法就是为哈希表服务的.当我们在使⽤形如HashMap, HashSet这样前⾯以Hash开头的集合类时,hashCode()就会被隐式调⽤以来创建哈希映射关系.稍后我们再对此进⾏说明.这⾥我们先重点关注⼀下hashCode()⽅法的写法.<Effective Java>中给出了⼀个能最⼤程度上避免哈希冲突的写法,但我个⼈认为对于⼀般的应⽤来说没有必要搞的这么⿇烦.如果你的应⽤中HashSet中需要存放上万上百万个对象时,那你应该严格遵循书中给定的⽅法.如果是写⼀个中⼩型的应⽤,那么下⾯的原则就已经⾜够使⽤了:要保证Coder对象中所有的成员都能在hashCode中得到体现.对于本例,我们可以这么写:@Overridepublic int hashCode() {int result = 17;result = result * 31 + name.hashCode();result = result * 31 + age;return result;}其中int result = 17你也可以改成20, 50等等都可以.看到这⾥我突然有些好奇,想看⼀下String类中的hashCode()⽅法是如何实现的.查⽂档知:"Returns a hash code for this string. The hash code for a String object is computed ass[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation. (The hash value of the empty string is zero.)"对每个字符的ASCII码计算n - 1次⽅然后再进⾏加和,可见Sun对hashCode的实现是很严谨的. 这样能最⼤程度避免2个不同的String会出现相同的hashCode的情况.重写equals()⽽不重写hashCode()的风险在Oracle的Hash Table实现中引⽤了bucket的概念.如下图所⽰:从上图中可以看出,带bucket的hash table⼤致相当于哈希表与链表的结合体.即在每个bucket上会挂⼀个链表,链表的每个结点都⽤来存放对象.Java通过hashCode()⽅法来确定某个对象应该位于哪个bucket中,然后在相应的链表中进⾏查找.在理想情况下,如果你的hashCode()⽅法写的⾜够健壮,那么每个bucket将会只有⼀个结点,这样就实现了查找操作的常量级的时间复杂度.即⽆论你的对象放在哪⽚内存中,我都可以通过hashCode()⽴刻定位到该区域,⽽不需要从头到尾进⾏遍历查找.这也是哈希表的最主要的应⽤.如:当我们调⽤HashSet的put(Object o)⽅法时,⾸先会根据o.hashCode()的返回值定位到相应的bucket中,如果该bucket中没有结点,则将 o 放到这⾥,如果已经有结点了, 则把 o 挂到链表末端.同理,当调⽤contains(Object o)时,Java会通过hashCode()的返回值定位到相应的bucket中,然后再在对应的链表中的结点依次调⽤equals()⽅法来判断结点中的对象是否是你想要的对象.下⾯我们通过⼀个例⼦来体会⼀下这个过程:我们先创建2个新的Coder对象:Coder c1 = new Coder("bruce", 10);Coder c2 = new Coder("bruce", 10);假定我们已经重写了Coder的equals()⽅法⽽没有重写hashCode()⽅法:@Overridepublic boolean equals(Object other) {System.out.println("equals method invoked!");if(other == this)return true;if(!(other instanceof Coder))return false;Coder o = (Coder)other;return .equals(name) && o.age == age;}然后我们构造⼀个HashSet,将c1对象放⼊到set中:Set<Coder> set = new HashSet<Coder>();set.add(c1);再执⾏:System.out.println(set.contains(c2));我们期望contains(c2)⽅法返回true, 但实际上它返回了false.c1和c2的name和age都是相同的,为什么我把c1放到HashSet中后,再调⽤contains(c2)却返回false呢?这就是hashCode()在作怪了.因为你没有重写hashCode()⽅法,所以HashSet在查找c2时,会在不同的bucket中查找.⽐如c1放到05这个bucket中了,在查找c2时却在06这个bucket中找,这样当然找不到了.因此,我们重写hashCode()的⽬的在于,在A.equals(B)返回true的情况下,A, B 的hashCode()要返回相同的值.我让hashCode()每次都返回⼀个固定的数⾏吗有⼈可能会这样重写:@Overridepublic int hashCode() {return 10;}如果这样的话,HashMap, HashSet等集合类就失去了其 "哈希的意义".⽤<Effective Java>中的话来说就是,哈希表退化成了链表.如果hashCode()每次都返回相同的数,那么所有的对象都会被放到同⼀个bucket中,每次执⾏查找操作都会遍历链表,这样就完全失去了哈希的作⽤.所以我们最好还是提供⼀个健壮的hashCode()为妙.总结以上就是本⽂关于重写hashCode()和equals()⽅法详细介绍的全部内容,希望对⼤家有所帮助。
布尔可满足性问题的复杂性及近似算法布尔可满足性问题,也被称为SAT问题,是计算机科学中一个经典的问题。
它涉及到一个布尔表达式是否存在一组变量的赋值使得该表达式为真。
SAT问题在理论计算机科学中被证明是一个NP完全问题,这意味着在当前的计算模型下,它是一种非常困难的问题。
本文将探讨SAT问题的复杂性,并介绍一些近似算法来解决这个问题。
一、SAT问题的复杂性分析SAT问题的复杂性理论上属于NP完全问题,这意味着如果存在一个高效的算法来解决一个NP完全问题,那么可以把这个算法用于解决其他所有的NP完全问题。
NP完全问题是指那些在多项式时间内可以验证一个解的问题。
虽然目前还没有找到一个多项式时间的算法来解决SAT问题,但是已经有很多研究人员提出了许多近似算法来解决这个问题。
接下来将介绍一些常见的近似算法。
二、近似算法1. 穷举法穷举法是一种直观且简单的算法,但是它的时间复杂度非常高。
穷举法的基本思路是枚举所有可能的变量赋值,然后验证是否存在一组赋值使得表达式为真。
虽然这个算法能够保证得到结果,但由于变量的数量呈指数级增长,计算时间会很长。
2. 改进的穷举法针对穷举法时间复杂度高的问题,研究者们提出了一些改进的穷举法。
例如,可以根据表达式的结构和特点来选择合适的变量赋值顺序,以减小搜索空间。
此外,还可以利用一些启发式算法来加速搜索过程。
这些方法可以在一定程度上提高算法的效率,但仍然无法在多项式时间内解决大规模的SAT问题。
3. 近似算法近似算法是指通过牺牲一定的精度来换取计算速度的算法。
它的基本思想是利用一些启发式规则和剪枝策略,在有限的时间内找到一个“接近最优解”的解。
近似算法的优势在于时间复杂度相对较低,可以应用于大规模的SAT问题。
近似算法的具体实现有很多种,最常见的包括贪心算法、遗传算法和模拟退火算法等。
三、近似算法的应用与局限性近似算法在实际应用中具有广泛的意义。
它不仅可以解决SAT问题,还可以应用于其他优化问题,如图着色、旅行商问题等。
Efficient SAT Solving:Beyond Supercubes∗Domagoj Babi´c Jesse Bingham Alan J.HuDepartment of Computer Science,University of British Columbia{babic,jbingham,ajh}@cs.ubc.caABSTRACTSAT(Boolean satisfiability)has become the primary Boolean rea-soning engine for many EDA applications,so the efficiency of SATsolving is of great practical importance.Recently,Goldberg et al.introduced supercubing,a different approach to search-space prun-ing,based on a theory that unifies many existing methods.Theirimplementation reduced the number of decisions,but no speedupwas obtained.In this paper,we generalize beyond supercubes,cre-ating a theory we call B-cubing,and show how to implement B-cubing in a practical solver.On extensive benchmark runs,usingboth real problems and synthetic benchmarks,the new technique iscompetitive on average with the newest version of ZChaff,is muchfaster in some cases,and is more robust.Categories and Subject DescriptorsJ.6[Computer-Aided Engineering]:Computer-Aided Design;I.2.8[Artificial Intelligence]:Problem Solving,Control Methods,and Search—backtracking,graph and tree search strategiesGeneral TermsAlgorithms,VerificationKeywordsSAT,formal verification,learning,search space pruning1.INTRODUCTIONThe problem of satisfiability of boolean formulas(SAT)is awell-known NP-complete problem.In short,given a boolean func-tion f,one needs either tofind a satisfying assignment or to provethat such doesn’t exist.SAT has been intensively used in many do-mains.Our focus is the application of SAT to structured problems,especially those resulting from EDA domain,like model checking(bounded[5]and unbounded[13]),FPGA routing[16],and ATPG1Mainly clause database organization,learning mechanism,andpreprocessing.2PLR was called Affirmative-Negative Rule in the original paper.Learning goes hand-in-hand with conflict-directed backtracking. Different solvers feature different learning strategies and clause deletion schemes.One thing in common is that they all traverse the implication graph in the reverse direction and add clauses that correspond to different cuts in the graph[23].From experimen-tal results[23]it seems that adding a clause that corresponds to the cut made before thefirst Unique Implication Point(1-UIP)is a better choice than other cuts proposed so far.Those results have recently been challenged by a suggestion that adding intermediate clauses that correspond to the cuts made closer to the conflict might perform better[18],but no experimental results were given.For a more extensive introduction into CDB and learning,and an exhaus-tive list of references,the reader is referred to[24].Although much work remains to be done,it is clear that learning schemes proposed so far can use only a fraction of the information inferable from conflicts.The limiting factors are memory require-ments and computation time required for reasoning.For example, due to memory constraints,it is impossible to add all the clauses that can be learned to the clause database.Similarly,some reason-ing techniques,like hyper-resolution[2],have been shown to be computationally too expensive to be performed at every step dur-ing SAT solving.Recently,a theory of essential points[17,9]has been proposed. The theory unifies many existing search space pruning schemes (like PLR,CDB,and learning)under a single theoretical framework and serves as a tool for developing new pruning techniques.A new pruning technique called supercubing was proposed as an example of application of the theory of essential points.Their solver was a proof of concept,and although supercubing reduced the num-ber of decisions,no actual speedup has been reported.Subsequent work[1]pointed out that supercubing is not readily compatible with learning and proposed an alternative backtracking and learn-ing scheme to integrate supercubing and learning.The reported performance results of the solver were comparable to an earlier ver-sion of ZChaff(v2003.11.04)[14].1.2ContributionsIn this paper,we generalize the theory of supercubing to intro-duce a new search-space pruning technique,performing a far more elaborate conflict analysis and moving beyond cubes as a way to store knowledge of learned conflicts.The theoretical ideal,which we dub B-cube,will blow up in space on practical problems,so we introduce a data structure Boolean Constraint Trees for compactly representing a safe approximation of the ideal B-cubes.The new technique can be made compatible with learning,but it requires significant modifications of the backtracking and decision making mechanisms,as in[1].We have implemented our new technique in an experimental solver HyperSAT,which features both learning and B-cubing.Although HyperSAT is in its infancy,we report en-couraging results and show that it can compete with leading-edge solvers like the newest version of ZChaff[14]on a wide range of problems.2.NEW PRUNING TECHNIQUEWe start with some basic definitions,and continue with explana-tions of supercubing and B-cubing.The proofs are omitted,as the space constraints do not permit the presentation of the entire theo-retical framework on which the proofs are based.We assume some basic familiarity with modern DPLL-based SAT solvers.Let B={0,1},and let V be afinite set of boolean variables.A literal is denoted by x b,where x∈V and b∈B.Define¯0=1and ¯1=0,then we say that the literal x¯b is obtained byflipping x b.A cube(clause)is a conjunction(disjunction)of literals in which each variable from V appears at most once.A minterm(also called an assignment)is a cube in which each variable appears exactly once.The set of all minterms is denoted by M.A CNF formula is a conjunction of clauses.For x∈V and a cube c,we writeflip(c,x) to denote the cube formed byflipping the x-literal of c(if it exists), and for a set of cubes S,we defineflip(S,x)={flip(c,x)|c∈S}. We assume a simple SAT solver which systematically explores a search tree without restarts or CDB,and the solver’s input is a CNF formulaϕ.We use T to denote the binary search tree traversed by the solver3.The nodes of T are labeled with variables of V.A decision is a node in T that has two children,the0-child and 1-child,that correspond respectively to assigning0and1to the decision’s variable.For a decision d and b∈B,we let d b denote the subtree of T rooted at the b-child of d.Assumingϕis not satisfiable,the leaves of T are called conflicts. Both supercubing and B-cubing require the solver to construct a decision conflict clause(DCC)whenever a conflict is encountered.A DCC contains all the decision variables involved in the conflict, and is typically computed by traversing the implication graph back-wards until the resolvent contains only decision literals[22].The negation of a DCC is a cube(via an application of DeMorgan’s Law)that we will call a certificate(of unsatisfiability)and denote by cert(u),where u is a conflict node in T.The certificate cert(u) has the property that no minterm m such that m→cert(u)will sat-isfyϕ.Consider a decision node d for variable x,and the certificates en-countered when exploring d b for some b∈B.Note that for any such certificate c,c may or may not contain x b,but c certainly doesn’t contain x¯b.We are interested in those certificates c that involve x b.Definition1.The set of all conflict nodes found in d b that in-clude the literal x b will be denoted A b(d),where x is the variable of d.Definition2.Suppose that there are no satisfying assignments in d b.The B-cube is then defined as a set of certificates B b(d)= {cert(u)|u∈A b(d)}and we also define B∗b(d)=flip(B b(d),x), where x is the variable of d.Definition3.Let S b(d)be the set of minterms defined by S b(d)= m∈M|m→c for some c∈B∗b(d)T HEOREM 1.Suppose d b has no satisfying assignments.Then for any minterm m found in d¯b that satisfiesϕ,we have m∈S b(d). Supercubing and B-cubing are pruning techniques that both ex-ploit Theorem1in the following manner.While exploring d b,some over-approximation S′of S b(d)is computed4.Then,while explor-ing d¯b,attention is restricted to the assignments of S′;i.e.assign-ments in d¯b that are not in S′are pruned.The difference between supercubing and B-cubing is that the latter’s over-approximation is a tighterfit than the former’s,hence B-cubing allows for more pruning.2.1SupercubingSupercubing over-approximates S b(d)using a single cube,de-fined as follows.The supercube sc b(d)is the least cube that sub-sumes S b(d),i.e.sc b(d)is the conjunction of all literalsℓsuch that S b(d)→ℓ.Example1.Suppose decisions in the search tree are(in order) x01,x12,x03,and let d be the decision node for x3.The solver explores the search subtree d0(i.e.x03)andfinds no solution.In the process of exploring d0,the followingfive certificates are constructed:c1=x12∧x14c2=x03∧x04∧x05∧x16c3=x01∧x05∧x06c4=x12∧x15∧x16c5=x01∧x03∧x04∧x15∧x06Here we have that B0(d)={c2,c5},and the least cube that cov-ers B0(d)is sc0(d)=x03∧x04.Hence,sinceflip(sc0(d),x3)over-approximates S0(d),in the subtree d1(i.e.afterflipping x3to1), the solver can immediately assign x04.The implementation of supercubing stores an array representing a supercube for each decision variable.Storing supercubes is not memory demanding,as the average size of the supercube per de-cision node is small(density of supercubes,[1]).Also,since deci-sions above d are the same in both d0and d1,such variables need not be stored in the supercube,which reduces space requirements further.Supercubing can prune the search space that can’t be pruned by learning,as explained in[9].An algorithm for computing super-cubes and a thorough discussion of the integration of supercubing and learning are given in[1].2.2B-cubingGoing back to Example1,the solver can immediately assign x04 after x13,but then there are no more literals that are common to all certificates of B0(d).However,there is a variable that appears in all certificates in B0(d),and that is x5.So the solver can choose x5as a new decision variable.If x15is chosen,we can immediately assign x06,since assignments in the space x13∧x15∧x16have alreadybeen certified to be unsatisfying by c4.Similarly,after picking x05,the variable assignment x16can be immediately asserted.In this manner,only assignment of S0(d)are considered after x3has been flipped,which is a legal pruning thanks to Theorem1.The fact that more information can be learned from certificates wasfirst observed by Nadel[15]and implemented in Jerusat SAT solver.It seems that Jerusat keeps all the certificates and does the analysis when a new decision is needed.Needless to say,such an approach requires a huge amount of memory and it is infeasi-ble even for moderately large problems.For that reason,Jerusat seems to keep certificates only for certain number of decision lev-els.When it backtracks out of the window,it discards certificates. This approach has several serious drawbacks.First,certificates contain a significant amount of redundant in-formation.In Example1,certificates c1and c2both contain infor-mation that only x04needs to be explored afterflipping x03.Clearly, if we had a suitable data structure to represent the corresponding B-cube,less memory would be required.Second,discarding certificates means that the search space will be less constrained and therefore more search will be needed.This is especially serious when the certificates are discarded for decision nodes close to the root of the search tree.For example,if the root decision node contains three literals in its supercube(or in the stem of its BCT data structure,as will be explained later),afterflipping the root node,the supercube would ideally reduce the search space eightfold.An advantage of the Jerusat approach is its simplicity.If all the conflicts are kept(within the predefined window),the reasoning procedure can be entirely implemented inside the decision engine. The technique we are proposing requires substantial changes in the backtracking mechanism,conflict analysis,and decision engine. When it comes to the integration of B-cubing and learning,one runs into the same compatibility problems as with supercubing. This problem has been extensively discussed in[1].3.APPROXIMATION OF B-CUBESAs mentioned before,keeping all the conflicts(i.e.entire B-cube)is not an option.Hence,we need tofind a more compact,ap-proximate representation that keeps as much relevant search space pruning information as possible.BDDs[6]or ZBDDs[11],per-haps with heuristic approximation techniques,certainly come to mind.Standard decision diagrams,however,are not suited for the task.In particular,a key advantage of SAT is the ability to have dif-ferent decision orders along different parts of the search,meaning that the data structure must efficiently handle different variable or-ders for different certificates,ruling out standard ordered decision diagrams.We have chosen instead to create a more appropriate data structure loosely based on decision trees[8]that is specifically designed to efficiently support the operations we need.Let’s consider some of the key properties of the DPLL algorithm and try to picture an ideal B-cube that would be of the greatest use for search space pruning.The SAT search tree is a binary tree, in which decision nodes have two outgoing edges5,and implied nodes have one.Ideally,our new pruning technique would provide the solver with a large number of literals that can be immediately assigned afterflipping some decision variable.Obviously,such lit-erals would need to be present in all the certificates,so we will call them supercubed literals.The more supercubed literals we have, the higher the probability that more unit clauses will be generated, increasing the chances for quick conflict detection.Thus thefirst desired property is to have as many supercubed literals as possible. After supercubed literals are removed from certificates,there are no more common literals,but there might be common variables. Common variable can be used to sort the certificates in two classes according to the phase of the corresponding literal.By recursively applying the partitioning and searching for common literals and variables we obtain a binary tree.This tree represents an approxi-mation of the set of all certificates in a compact manner.The case when there are no common variables is more complicated.Example2.Suppose x1is the variable of the root r of the search tree,and the B-cube B0(r)is the set x01∧x02∧x13,x01∧x02∧x04,x01∧x02∧x15 .Afterflipping x01,the solver can assign the supercubed variable x02.At this point we know that either x13or x04or x15need to be explored.Whichever choice the solver makes,it might need to backtrack later to that choice and try the remaining ones.Faced with a multiway choice,the solver would need some heuristic to determine the order of choice exploration.Choosing the next deci-sion variable from the priority queue might be a better option.As there is no clear intuition about whether multiway nodes would actually improve performance,and because multiway nodes are not easily added on top of DPLL,an approximation of the B-cube could simply discard such literals.If the B-cube is approximated by a binary tree,the stem of the tree clearly contains supercubed variables and corresponds to a su-percube.As it has been proven in[9],supercubing subsumes PLR. From the fact that such an approximation of B-cubing contains all supercubed literals as a stem,it follows that the approximation also subsumes PLR.3.1Boolean Constraint TreesBoolean Constraint Trees(BCTs)are presented in this section as an approximation of B-cubes.Definition4.A Boolean Constraint Tree is a rooted binary tree such that branch nodes are labeled with a variable and have two outgoing edges.Literal nodes are labeled with a literal and have one outgoing edge.Any variable can appear at most once on a path from the root to a leaf.Given a BCT C,the prefix of node x is defined to be the cube of literals on the path from the root of the BCT to the node x and denoted by pref C(x).A leaf node can be either a literal node or a termination node.A termination node t is always a child of a branch node and marks that there were at least two certificates containing cube pref C(t),but no other common literals or variables.There are two simplification rules for BCTs.A branch node with both children being termination nodes contains no useful informa-tion and can be discarded.The second rule says that two adjacent branches cannot contain equal literals.Such literals must be in-serted above the branch as they are common to both paths.of our new pruning technique.The sets represent typical practical applications of SAT with an emphasis on EDA problems.The Pico-Java instances result from Bounded Model Checking(BMC)of the Sun PicoJava II TM microprocessor.6The second set(IBM BMC) is an encoding of BMC of real industrial hardware designs.7The third set contains the well-known barrel,longmult,and queueinvar BMC benchmarks from CMU.8The next three sets are all from Fadi Aloul9and represent SAT encodings of FPGA routing and integer factorization problems.The seventh set is a SAT encod-ing of Constraint Satisfaction Problems(CSP).10Only three sub-sets(frb30,35,40)were used from this set,as no solver could solve the remaining ones.The last set is the ruleDecisionsf+BCT35418401f+BCT10410396/∼kenmcmil/satbench.html7rmatik.tu-darmstadt.de/SATLIB/ Benchmarks/SAT/BMC/description.html8/∼modelcheck/bmc/bmc-benchmarks.html9/∼faloul/benchmarks.html10/∼kexu/benchmarks/ benchmarks.htm11/projects/verification/RBBenchmark Set1.PicoJava BMC (76)10756(2)19952(5)all1183.CMU BMC (34)77111360all30271(7)5.FPGA SAT (11)110.23all176347.CSP (15)18130(4)4246rule268440(71)274414(74)Table 1:Experimental Results..timeout..timeoutH y p e r S A TZChaff (a)PicoJava TM....H y p e r S A TZChaff (b)IBM BMC....H y p e r S A TZChaff (c)CMU BMC....H y p e r S A TZChaff(d)FPGA SAT..timeout..timeoutH y p e r S A TZChaff (e)FPGA UNS ..timeout..timeoutH y p e r S A TZChaff (f)INT FACT..timeout..timeoutH y p e r S A TZChaff (g)CSP ..timeout..timeoutH y p e r S A TZChaff(h)IBM FVSFigure 2:Scatter plotsAlgorithm for Propositional Satisfiability.IEEE put.,48(5):506–521,1999.[13]K.L.McMillan.Interpolation and SAT-based modelchecking.In CAV 03:Computer-Aided Verification,LNCS 2725,pages 1–13.Springer,2003.[14]M.W.Moskewicz,C.F.Madigan,Y .Zhao,L.Zhang,and S.Malik.Chaff:engineering an efficient SAT solver.In Proceedings of the Design Automation Conference ,pages 530–535.ACM Press,2001.[15]A.Nadel.Backtrack Search Algorithms for Propositional Logic Satisfiability:Review and Innovations.Master’s thesis,Tel-Aviv University,2002.[16]G.Nam,K.Sakallah,and R.Rutenbar.A booleansatisfiability-based incremental rerouting approach with application to FPGAs.In Proceedings of the conference on Design,Automation and Test in Europe ,pages 560–565.IEEE Press,2001.[17]M.R.Prasad.Propositional Satisfiability Algorithms in EDA Applications .PhD thesis,University of California at Berkeley,2001.[18]L.Ryan.Efficient algortihtms for clause-learning SAT solvers.Master’s thesis,Simon Fraser University,2004.[19]P.Stephan,R.Brayton,and A.Sangiovanni-Vincentelli.Combinational test generation using satisfiability.IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems ,15(9):1167–1176,Sept 1996.[20]J.P.Warners and H.van Maaren.A two phase algorithm for solving a class of hard satisfiability problems.Operations Research letters ,23:81–88,1998.[21]J.P.Warners and H.van Maaren.Recognition of tractable satisfiability problems through balanced polynomial representations.In 5th Twente Workshop on Graphs and Combinatorial Optimization ,pages 229–244.Elsevier Science Publishers B.V .,2000.[22]H.Zhang and M.E.Stickel.An efficient Algorithm for Unit Propagation.In Proceedings of the Fourth International Symposium on Artificial Intelligence and Mathematics (AI-MATH’96),Fort Lauderdale (Florida USA),1996.[23]L.Zhang,C.F.Madigan,M.H.Moskewicz,and S.Malik.Efficient conflict driven learning in a boolean satisfiability solver.In Proceedings of the International Conference on Computer-Aided Design ,pages 279–285.IEEE Press,2001.[24]L.Zhang and S.Malik.The quest for efficient booleansatisfiability solvers.In Proceedings of the 18th International Conference on Automated Deduction ,pages 295–313.Springer-Verlag,2002.。
布尔函数敏感度猜想介绍布尔函数敏感度猜想(Boolean Function Sensitivity Conjecture)是一个关于布尔函数的数学猜想。
布尔函数是一种将每个输入位映射到一个输出位的函数,其中输入和输出位均为布尔值(0或1)。
敏感度是用来描述对于一个布尔函数而言,改变输入的一位对输出的影响程度。
布尔函数的敏感度猜想探讨了敏感度的上界和下界之间的关系。
敏感度定义敏感度是衡量在改变输入的一位时,布尔函数输出会发生多大变化的度量。
对于一个布尔函数 f,令 n 为输入位的数量,则该函数的敏感度定义为:S(f) = max_{x {0,1}^n} _{i=1}^{n} |f(x) - f(x^i)|其中 x^i 是将第 i 位的值取反后得到的输入。
敏感度上界敏感度上界是指对于一个布尔函数 f,它的任何输入的敏感度都不超过某个值。
具体来说,如果存在一个常数 T,使得对于任意的输入 x 和任意的 i,满足 |f(x) - f(x^i)| ≤ T,则称 T 为该布尔函数的敏感度上界。
猜想认为,对于任意的布尔函数 f,它的敏感度上界为 O(n)。
敏感度下界敏感度下界是指对于一个布尔函数 f,它的某个输入的敏感度不小于某个值。
具体来说,如果对于某个输入 x 和某个 i,满足 |f(x) - f(x^i)| ≥ C,则称 C 为该布尔函数的敏感度下界。
猜想认为,对于任意的布尔函数 f,它的敏感度下界为Ω(n/log n)。
证明进展目前,布尔函数敏感度猜想还未被证明或推翻。
但是,有一些与敏感度猜想相关的证明进展和研究成果。
线性敏感度上界线性敏感度是一种敏感度的度量方式,其中线性敏感度为 1 表示改变输入的一位时,布尔函数的输出完全改变。
Van Melkebeek等人在2007年的一篇论文中证明了布尔函数的线性敏感度上界为O(n²/log n)。
唯一性敏感度上界唯一性敏感度是另一种敏感度的度量方式,其中唯一性敏感度为 1 表示改变输入的一位时,布尔函数的输出至多只有一个位置发生改变。
Boolean Satisfiabilitywith Transitivity ConstraintsRandal E.BryantMiroslav N.V elevCarnegie Mellon UniversityJune,2000CMU-CS-00-101School of Computer ScienceCarnegie Mellon UniversityPittsburgh,PA15213Supported,in part,by the Semiconductor Research Corporation under contract00-DC-684Keywords:Formal verification,Boolean satisfiability,Decision proceduresAbstractWe consider a variant of the Boolean satisfiability problem where a subset of the propositional variables appearing in formula sat encode a symmetric,transitive,binary relation over ele-ments.Each of these relational variables,,for,expresses whether or not the relation holds between elements and.The task is to eitherfind a satisfying assignment to sat that also satisfies all transitivity constraints over the relational variables(e.g.,), or to prove that no such assignment exists.Solving this satisfiability problem is thefinal and most difficult step in our decision procedure for a logic of equality with uninterpreted functions.This procedure forms the core of our tool for verifying pipelined microprocessors.To use a conventional Boolean satisfiability checker,we augment the set of clauses expressing sat with clauses expressing the transitivity constraints.We consider methods to reduce the number of such clauses based on the sparse structure of the relational variables.To use Ordered Binary Decision Diagrams(OBDDs),we show that for some sets,the OBDD representation of the transitivity constraints has exponential size for all possible variable orderings. By considering only those relational variables that occur in the OBDD representation of sat,our experiments show that we can readily construct an OBDD representation of the relevant transitivity constraints and thus solve the constrained satisfiability problem.1IntroductionConsider the following variant of the Boolean satisfiability problem.We are given a Booleanformula sat over a set of variables.A subset symbolically encodes a binary relationover elements that is reflexive,symmetric,and transitive.Each of these relational variables,,where,expresses whether or not the relation holds between elements and .Typically,will be“sparse,”containing much fewer than the possible variables. Note that when for some value of and of,this does not imply that the relation does not hold between elements and.It simply indicates that sat does not directly depend on therelation between elements and.A transitivity constraint is a formula of the form(1) where equals when and equals when.Let denote the set of all transitivity constraints that can be formed from the relational variables.Our task is tofind an assignment that satisfies sat,as well as every constraint in.Goel, et al.[GSZAS98]have shown this problem is NP-hard,even when sat is given as an Ordered Binary Decision Diagram(OBDD)[Bry86].Normally,Boolean satisfiability is trivial given an OBDD representation of a formula.We are motivated to solve this problem as part of a tool for verifying pipelined microprocessors[VB99].Our tool abstracts the operation of the datapath as a set of uninterpreted functions and uninterpreted predicates operating on symbolic data.We prove that a pipelined processor has behavior matching that of an unpipelined reference model using the symbolicflushing technique developed by Burch and Dill[BD94].The major computational task is to decide the validity of a formula ver in a logic of equality with uninterpreted functions[BGV99a,BGV99b].Our decision procedure transforms verfirst by replacing all function application terms with terms over a set of domain variables.Similarly,all predicate applications are replaced by formulas over a set of newly-generated propositional variables.The result is a formula ver containing equations of the form,where.Each of these equations is then encoded by introducing a relational variable,similar to the method proposed by Goel,et al.[GSZAS98].The result of the translation is a propositional formula ver expressing the verification condition over both the relational variables and the propositional variables appearing in ver.Let sat denote ver,the complement of the formula expressing the translated verification condition.To capture the transitivity of equality,e.g.,that, we have transitivity constraints of the form.Finding a satisfying assignment to sat that also satisfies the transitivity constraints will give us a counterexample to the original verification condition ver.On the other hand,if we can prove that there are no such assignments, then we have proved that ver is universally valid.We consider three methods to generate a Boolean formula trans that encodes the transitivityconstraints.The direct method enumerates the set of chord-free cycles in the undirected graph having an edge for each relational variable.This method avoids introducing addi-tional relational variables but can lead to a formula of exponential size.The dense method usesrelational variables for all possible values of and such that.We can thenaxiomatize transitivity by forming constraints of the form for all distinct values of,,and.This will yield a formula that is cubic in.The sparse method augments with additional relational variables to form a set of variables,such that the resulting graph is chordal [Rose70].We then only require transitivity constraints of the form such that .The sparse method is guaranteed to generate a smaller formula than thedense method.To use a conventional Boolean Satisfiability(SA T)procedure to solve our constrained satisfia-bility problem,we run the checker over a set of clauses encoding both sat and trans.The latestversion of the FGRASP SA T checker[M99]was able to complete all of our benchmarks,although the run times increase significantly when transitivity constraints are enforced.When using Ordered Binary Decision Diagrams to evaluate satisfiability,we could generateOBDD representations of sat and trans and use the APPLY algorithm to compute an OBDD representation of their conjunction.From this OBDD,finding satisfying solutions would be trivial. We show that this approach will not be feasible in general,because the OBDD representation of trans can be intractable.That is,for some sets of relational variables,the OBDD representation of the transitivity constraint formula trans will be of exponential size regardless of the variableordering.The NP-completeness result of Goel,et al.shows that the OBDD representation of trans may be of exponential size using the ordering previously selected for representing sat as an OBDD.This leaves open the possibility that there could be some other variable ordering that would yield efficient OBDD representations of both sat and trans.Our result shows that transitivity constraints can be intrinsically intractable to represent with OBDDs,independent of the structure of sat.We present experimental results on the complexity of constructing OBDDs for the transitivity constraints that arise in actual microprocessor verification.Our results show that the OBDDs can indeed be quite large.We consider two techniques to avoid constructing the OBDD representation of all transitivity constraints.Thefirst of these,proposed by Goel,et al.[GSZAS98],generates implicants(cubes)of sat and rejects those that violate the transitivity constraints.Although this method suffices for small benchmarks,wefind that the number of implicants generated for our larger benchmarks grows unacceptably large.The second method determines which relational variables actually occur in the OBDD representation of sat.We can then apply one of our three techniques for encoding the transitivity constraints in order to generate a Boolean formula for the transitivity constraints over this reduced set of relational variables.The OBDD representation of this formula is generally tractable,even for the larger benchmarks.2BenchmarksOur benchmarks[VB99]are based on applying our verifier to a set of high-level microprocessor designs.Each is based on the DLX RISC processor described by Hennessy and Patterson[HP96]: 1DLX-C:is a single-issue,five-stage pipeline capable of fetching up to one new instruction every clock cycle.It implements six instruction types:register-register,register-immediate,Circuit Domain Propositional Equations 1DLX-C1342372558118 2DLX-CA-t2DLX-CC2570143 min.avg.max.To create more challenging benchmarks,we generated variants of the circuits that require en-forcing transitivity in the verification.For example,the normal forwarding logic in the Execute stage of1DLX-C must determine whether to forward the result from the Memory stage instruc-tion as either one or both operand(s)for the Execute stage instruction.It does this by comparing the two source registers ESrc1and ESrc2of the instruction in the Execute stage to the destination register MDest of the instruction in the memory stage.In the modified circuit,we changed the by-pass condition ESrc1MDest to be ESrc1MDest ESrc1ESrc2ESrc2MDest. Given transitivity,these two expressions are equivalent.For each pipeline,we introduced four such modifications to the forwarding logic,with different combinations of source and destination registers.These modified circuits are named1DLX-C-t,2DLX-CA-t,and2DLX-CC-t.To study the problem of counterexample generation for buggy circuits,we generated105vari-ants of2DLX-CC,each containing a small modification to the control logic.Of these,5were found to be functionally correct,e.g.,because the modification caused the processor to stall un-necessarily,yielding a total of100benchmark circuits for counterexample generation.Table1gives some statistics for the benchmarks.The number of domain variables ranges between13and25,while the number of equations ranges between27and143.The verification condition formulas ver also contain between42and77propositional variables expressing the operation of the control logic.These variables plus the relational variables comprise the set of variables in the propositional formula sat.The circuits with modifications that require en-forcing transitivity yield formulas containing up to19additional equations.Thefinal three lines summarize the complexity of the100buggy variants of2DLX-CC.We apply a number of sim-plifications during the generation of formula sat,and hence small changes in the circuit can yield significant variations in the formula complexity.3Graph FormulationOur definition of(Equation1)places no restrictions on the length or form of the tran-sitivity constraints,and hence there can be an infinite number.We show that we can construct a graph representation of the relational variables and identify a reduced set of transitivity constraints that,when satisfied,guarantees that all possible transitivity constraints are satisfied.By introduc-ing more relational variables,we can alter this graph structure,further reducing the number of transitivity constraints that must be considered.For variable set,define the undirected graph as containing a vertex for,and an edge for each variable.For an assignment of Boolean values to the relational variables,define the labeled graph to be the graph with each edge labeled as a 1-edge when,and as a0-edge when.A path is a sequence of vertices having edges between successive elements. That is,each element of the sequence()denotes a vertex:,while each successive pair of elements and()forms an edge We consider each edge for to also be part of the path.A cycle is a path of the form.Proposition1An assignment to the variables in violates transitivity if and only if some cycle in contains exactly one0-edge.Proof:If.Suppose there is such a cycle.Letting be the vertex at one end of the0-edge,we can trace around the cycle,giving a sequence of vertices,where is the vertex at the other end of the0-edge.The assignment has for,and, and hence it violates Equation1.Only If.Suppose the assignment violates a transitivity constraint given by Equation1.Then, we construct a cycle of vertices such that only edge is a0-edge.A path is said to be acyclic when for all.A cycleis said to be simple when its prefix is acyclic.Proposition2An assignment to the variables in violates transitivity if and only if some simple cycle in contains exactly one0-edge.Proof:The“if”portion of this proof is covered by Proposition1.The“only if”portion is proved by induction on the number of variables in the antecedent of the transitivity constraint (Equation1.)That is,assume a transitivity constraint containing variables in the antecedent is violated and that all other violated constraints have at least variables in their antecedents.If there are no values and such that and,then the cycle is simple. If such values and exist,then we can form a transitivity constraint:This transitivity constraint contains fewer than variables in the antecedent,but it is also violated. This contradicts our assumption that there is no violated transitivity constraint with fewer than variables in the antecedent.Define a chord of a simple cycle to be an edge that connects two vertices that are not adjacent in the cycle.More precisely,for a simple cycle,a chord is an edge in such that,with,and either or.A cycle is said to be chord-free if it is simple and has no chords.Proposition3An assignment to the variables in violates transitivity if and only if some chord-free cycle in contains exactly one0-edge.Proof:The“if”portion of this proof is covered by Proposition1.The“only if”portion is proved by induction on the number of variables in the antecedent of the transitivity constraint (Equation1.)Assume a transitivity constraint with variables is violated,and that no transitivity constraint with fewer variables in the antecedent is violated.If there are no values of and such that there is a variable with and either or,then the corresponding cycle is chord-free.If such values of and exist,then consider the two cases illustrated in Figure 1,where0-edges are shown as dashed lines,1-edges are shown as solid lines,and the wavy lines0-Edge1-EdgeFigure1:Case Analysis for Proposition3.0-Edges are shown as dashed lines.When a cycle rep-resenting a transitivity violation contains a chord,we canfind a smaller cycle that also represents a transitivity violation.represent sequences of1-edges.Case1:Edge is a0-edge(shown on the left).Then the transitivity constraint:is violated and has fewer than variables in its antecedent.Case2:Edge is a1-edge(shown on the right).Then the transitivity constraint:is violated and has fewer than variables.Both cases contradict our assumption that there is no violated transitivity constraint with fewer than variables in the antecedent.Each length cycle yields constraints,given by the following clauses.Each clause is derived by expressing Equation1as a disjunction.(2)For a set of relational variables,we define trans to be the conjunction of all transitivity constraints for all chord-free cycles in the graph.Theorem1An assignment to the relational variables will satisfy all of the transitivity con-straints given by Equation1if and only if it satisfies trans.This theorem follows directly from Proposition3and the encoding given by Equation2.3.1Enumerating Chord-Free CyclesTo enumerate the chord-free cycles of a graph,we exploit the following properties.An acyclic path is said to have a chord when there is an edge in such thatwith,and either or.We classify a chord-free path as terminal whenis in,and as extensible otherwise.Proposition4A path is chord-free and terminal if and only if the cycleis chord-free.This follows by noting that the conditions imposed on a chord-free path are identical to those for a chord-free cycle,except that the latter includes a closing edge.A proper prefix of path is a path such that. Proposition5Every proper prefix of a chord-free path is chord-free and extensible.Clearly,any prefix of a chord-free path is also chord-free.If some prefix with were terminal,then any attempt to add the edge would yield either a simple cycle (when),some other cycle(when for some),or a path havingas a chord.Given these properties,we can enumerate the set of all chord-free paths by breadthfirst expan-sion.As we enumerate these paths,we also generate,the set of all chord-free cycles.Defineto be the set of all extensible,chord-free paths having vertices,for.Initially we have,and.Given set,we generate set and add some cycles of length to.For each path,we consider the path for each edge in.When for some,we classify the path as cyclic.When there is an edge in for some,we classify the path as having a chord.When there is an edge in,we add the cycle to.Otherwise,we add the path to.After generating all of these paths,we can use the set to generate the set of all chord-free cycles.For each terminal,chord-free cycle having vertices,there will be members of—each of the edges of the cycle can serve as the closing edge,and a cycle can traverse the closing edge in either direction.To generate the set of clauses given by Equation2,we simply need to choose one element of for each closing edge,e.g.,by considering only cycles for which.As Figure2indicates,there can be an exponential number of chord-free cycles in a graph. In particular,thisfigure illustrates a family of graphs with vertices.Consider the cycles passing through the diamond-shaped faces as well as the edge along the bottom.For each diamond-shaped face,a cycle can pass through either the upper vertex or the lower vertex.Thus there are such cycles.In addition,the edges forming the perimeter of each face create a chord-free cycle,giving a total of chord-free cycles.The columns labeled“Direct”in Table2show results for enumerating the chord-free cycles for our benchmarks.For each correct microprocessor,we have two graphs:one for which transitivity constraints played no role in the verification,and one(indicated with a“t”at the end of the name) modified to require enforcing transitivity constraints.We summarize the results for the transitivity1DLX-C78286858379534842682041182,3939,5721726972,091 2DLX-CA-t3002,3006,9002DLX-CC3002,3006,9001432,1368,3641938582,574 min.2311,5404,620avg.3002,3006,900max.2992,2926,8771205601,680402293,05677982946307,14021,4208465,7721,472,1842064081,2242,01641,664124,9923.2Adding More Relational VariablesEnumerating the transitivity constraints based on the variables in runs the risk of generating a Boolean formula of exponential size.We can guarantee polynomial growth by considering a larger set of relational variables.In general,let be some set of relational variables such that, and let trans be the transitivity constraint formula generated by enumerating the chord-free cycles in the graph.Theorem2If is the set of relational variables in sat and,then the formula sat trans is satisfiable if and only if sat trans is satisfiable.We introduce a series of lemmas to prove this theorem.For a propositional formula over a set of variables and an assignment,define the valuation of under,denoted ,to be the result of evaluating formula according to assignment.Wefirst prove that we can extend any assignment over a set of relational variables to one over a superset of these variables yielding identical valuations for both transistivity constraint formulas.Lemma1For any sets of relational variables and such that,and for any assignment ,such that trans,there is an assignment such that transProof:We consider the case where.The general statement of the proposition then holds by induction on.Define assignment to be:Graph has a path of1-edges from node to node.otherwiseWe consider two cases:1.If,then any cycle in through must contain a0-edge other than.Hence adding this edge does not introduce any transitivity violations.2.If,then there must be some path of1-edges between nodes and in.In order for the introduction of1-edge to create a transitivity violation,there must also be some path between nodes and in containing exactly one0-edge.But then we could concatenate paths and to form a cycle in containing exactly one0-edge,implying that trans.We conclude therefore that adding 1-edge does not introduce any transitivity violations.Lemma2For and for any assignment,such that trans,we also have transProof:We note that any cycle in must be present in and have the same edge labeling.Thus,if has no cycle with a single0-edge,then neither does.We now return to the proof of Theorem2.Proof:Suppose that sat trans is satisfiable,i.e.,there is some assignment such that sat trans.Then by Lemma1we canfind an assignment such that trans.Furthermore,since the construction of by Lemma1preserves the values assigned to all variables in,and these are the only relational variables occurring in sat,we can conclude that sat.Therefore sat trans is satisfiable.Suppose on the other hand that sat trans is satisfiable,i.e.,there is some assignment such that sat trans.Then by Lemma2we also have trans,and hence sat trans is satisfiable.Our goal then is to add as few relational variables as possible in order to reduce the size of the transitivity formula.We will continue to use our path enumeration algorithm to generate the transitivity formula.3.3Dense EnumerationFor the dense enumeration method,let denote the set of variables for all values of and such that.Graph is a complete,undirected graph.In this graph, any cycle of length greater than three must have a chord.Hence our algorithm will enumerate transitivity constraints of the form,for all distinct values of,,and. The graph has edges and chord-free cycles,yielding a total oftransitivity constraints.The columns labeled“Dense”in Table2show the complexity of this method for the benchmark circuits.For the smaller graphs1DLX-C,1DLX-C-t,and,this method yields more clauses than direct enumeration of the cycles in the original graph.For the larger graphs,however, it yields fewer clauses.The advantage of the dense method is most evident for the mesh graphs, where the cubic complexity is far superior to exponential.3.4Sparse EnumerationWe can improve on both of these methods by exploiting the sparse structure of.Like the dense method,we want to introduce additional relational variables to give a set of variables such that the resulting graph becomes chordal[Rose70].That is,the graph has the property that every cycle of length greater than three has a chord.Chordal graphs have been studied extensively in the context of sparse Gaussian elimination.In fact,the problem offinding a minimum set of additional variables to add to our set is identical to the problem offinding an elimination ordering for Gaussian elimination that minimizes the amount offill-in.Although this problem is NP-complete[Yan81],there are good heuristic solutions.InCircuit sat trans sat RatioSatisfiable?Secs.Satisfiable?Secs.N3 1.4 1DLX-C-t N92DLX-CA N1,275Y3N.A.N5,035 2.0 2DLX-CC-t N15,003Full Y10.2Buggy Y125 2.32DLX-CC Y2,18669.4Table3:Performance of FGRASP on Benchmark Circuits.Results are given both without and with transitivity constraints.particular,our implementation proceeds as a series of elimination steps.On each step,we remove some vertex from the graph.For every pair of distinct,uneliminated vertices and such that the graph contains edges and,we add an edge if it does not already exist.The original graph plus all of the added edges then forms a chordal graph.To choose which vertex to eliminate on a given step,our implementation uses the simple heuristic of choosing the vertex with minimum degree.If more than one vertex has minimum degree,we choose one that minimizes the number of new edges added.The columns in Table2labeled“Sparse”show the effect of making the benchmark graphs chordal by this method.Observe that this method gives superior results to either of the other two methods.In our implementation we have therefore used the sparse method to generate all of the transitivity constraint formulas.4SAT-Based Decision ProceduresMost Boolean satisfiability(SA T)checkers take as input a formula expressed in clausal form. Each clause is a set of literals,where a literal is either a variable or its complement.A clause denotes the disjunction of its literals.The task of the checker is to eitherfind an assignment to the variables that satisfies all of the clauses or to determine that no such assignment exists.We can solve the constrained satisfiability problem using a conventional SA T checker by generating a set of clauses trans representing trans and a set of clauses sat representing the formula sat. We then run the checker on the combined clause set sat trans tofind satisfying solutions tosat trans.In experimenting with a number of Boolean satisfiability checkers,we have found that FGRASP [MS99]has the best overall performance.The most recent version can be directed to periodically restart the search using a randomly-generated variable assignment[M99].This is thefirst SA T checker we have tested that can complete all of our benchmarks.All of our experiments wereconducted on a336MHz Sun UltraSPARC II with1.2GB of primary memory.As indicated by Table3,we ran FGRASP on clause sets sat and trans sat,i.e.,both with-out and with transitivity constraints.For benchmarks1DLX-C,2DLX-CA,and2DLX-CC, the formula sat is unsatisfiable.As can be seen,including transitivity constraints increases the run time significantly.For benchmarks1DLX-C-t,2DLX-CA-t,and2DLX-CC-t,the for-mula sat is satisfiable,but only because transitivity is not enforced.When we add the clauses for trans,the formula becomes unsatisfiable.For the buggy circuits,the run times for sat range from under1second to over36minutes.The run times for trans sat range from less than one second to over12hours.In some cases,adding transitivity constraints actually decreased the CPU time(by as much as a factor of5),but in most cases the CPU time increased(by as much as a factor of69).On average(using the geometric mean)adding transitivity constraints increased the CPU time by a factor of2.3.We therefore conclude that satisfiability checking with transitivity constraints is more difficult than conventional satisfiability checking,but the added complexity is not overwhelming.5OBDD-Based Decision ProceduresA simple-minded approach to solving satisfiability with transitivity constraints using OBDDs would be to generate separate OBDD representations of trans and sat.We could then use the A PPLY operation to generate an OBDD for trans sat,and then eitherfind a satisfying assignment or determine that the function is unsatisfiable.We show that for some sets of relational variables,the OBDD representation of trans can be too large to represent and manipulate.In our experiments,we use the CUDD OBDD package with dynamic variable reordering by sifting.5.1Lower Bound on the OBDD Representation of transWe prove that for some sets,the OBDD representation of trans may be of exponential size for all possible variable orderings.As mentioned earlier,the NP-completeness result proved by Goel,et al.[GSZAS98]has implications for the complexity of representing trans as an OBDD.They showed that given an OBDD sat representing formula sat,the task offinding a satisfying assignment of sat that also satisfies the transitivity constraints in is NP-complete in the size of sat.By this,assuming,we can infer that the OBDD representa-tion of trans may be of exponential size when using the same variable ordering as is used in sat.Our result extends this lower bound to arbitrary variable orderings and is independent of the vs.problem.Let denote a planar mesh consisting of a square array of vertices.For example, Figure3shows the graph for.Being a planar graph,the edges partition the plane into faces. As shown in Figure3we label these for.There are a total ofsuch faces.One can see that the set of edges forming the border of each face forms a chord-free cycle of.As shown in Table2,many other cycles are also chord-free,e.g.,the perimeter of any rectangular region having height and width greater than1,but we will consider only the cycles。