First-order Logic as a Constraint Programming Language
First-Order Logic
• Relations can be unary as well.
tall(amy)
Let’s blur the distinction…
• Constants refer to objects, functions and relationships.
joe, mary, loves, happy, hat
E.g. How about saying that Jimmy Durante has a big nose? durante is an object and nose_of (durante) is a function that constructs an object from the argument object. Then, we can write: big(nose_of (durante)) Note: We are allowed to relate sentences only. So, we can say: loves(quincy, dog_of (quincy)) ∧ loves(quincy, cat_of (quincy)) But not, loves(quincy, dog_of (quincy) ∧ cat_of (quincy)) because dog_of (quincy), cat_of (quincy) aren’t sentences, they are objects. E.g. Quincy loves his dog. loves(quincy, dog_of (quincy))
More about Conceptualization I
• A function is a kind of interrelationship among the objects in a universe of discourse. • Although we can define many functions for a given set of objects, in conceptualizing a portion of the world we usually emphasize some functions and ignore others. • The set of functions emphasized in a conceptualization is called the functional basis set. • E.g. in our blocks world, it would make sense to define a (partial) function Hat that maps a block into the block on top of it, if such exists. The tuples corresponding to this function are: • {<B,A>, <C,B>, <E,D>}
Formal Description of OCL Specification Patterns for Behavioral Specification of Software C
Formal Description of OCL Specification Patterns for Behavioral Specification of Software ComponentsJörg AckermannChair of Business Informatics and Systems Engineering,University of Augsburg, Universitätsstr. 16, 86135 Augsburgjoerg.ackermann@wiwi.uni-augsburg.deAbstract. The Object Constraint Language (OCL) is often used for behavioralspecification of software components. One current problem in specifying be-havioral aspects comes from the fact that editing OCL constraints manually istime consuming and error-prone. To simplify constraint definition we proposeto use specification patterns for which OCL constraints can be generated auto-matically. In this paper we outline this solution proposal and develop a wayhow to formally describe such specification patterns on which a library of reus-able OCL specifications is based.Keywords. Software Component Specification, OCL, Specification Patterns1 IntroductionThe Object Constraint Language (OCL) [20] has great relevance for component-based software engineering (CBSE): A crucial prerequisite for applying CBSE successfully is an appropriate and standardized specification of software components [27]. Behav-ioral aspects of components are often specified using OCL (see Sect. 2). From this results one of the current problems in component specifications: Editing OCL con-straints manually is time consuming and error-prone (see Sect. 3).To simplify constraint definition we propose to utilize specification patterns for which OCL constraints can be generated automatically (see Sect. 4). [4] identifies nine patterns that frequently occur in behavioral specifications of software components. In this paper we develop a solution how to formally describe specification patterns that enable a precise pattern specification and aid the implementation of constraint genera-tors (Sect. 5). We conclude with discussion of related work (Sect. 6) and a summary (Sect. 7).The main contributions of this paper are: the proposal to use specification patterns to simplify component specifications and the formal description of specification pat-terns by use of so called OCL pattern functions – together with the identified patterns we obtain a library of reusable OCL specifications.The results are not specific for software components and might therefore be interesting for any user of OCL con-straints.2 Specification of Software ComponentsThe basic paradigm of component-based software engineering is to decouple the pro-duction of components (development for reuse) from the production of complete sys-tems out of components (development by reuse). Applying CBSE promises (amongst others) a shorter time to market, increased adaptability and reduced development costs [8,25].A critical success factor for CBSE is the appropriate and standardized specification of software components: the specification is prerequisite for a composition methodol-ogy and tool support [23] as well as for reuse of components by third parties [26]. With specification of a component we denote the complete, unequivocal and precise description of its external view - that is which services a component provides under which conditions [27].Various authors addressed specifications for specific tasks of the development process as e.g. design and implementation [9,10], component adaptation [28] or com-ponent selection [15]. Approaches towards comprehensive specification of software components are few and include [7,23,27]. Objects to be specified are e.g. business terms, business tasks (domain-related perspective), interface signatures, behavior and coordination constraints (logical perspective) and non-functional attributes (physical perspective).Behavioral specifications (which are topic of this paper) describe how the compo-nent behaves in general and in borderline cases. This is achieved by defining con-straints (invariants, pre- and postconditions) based on the idea of designing applica-tions by contract [18]. OCL is the de-facto standard technique to express such con-straints – cf. e.g. [9,10,23,27].Fig. 1. Interface specification of component SalesOrderProcessingTo illustrate how behavioral aspects of software components are specified we intro-duce a simplified exemplary component SalesOrderProcessing. The business task of the component is to manage sales orders. This component is used as example through-out the rest of the paper.16 J. AckermannFig. 1 shows the interface specification of SalesOrderProcessing using UML [21]. We see that the component offers the interface ISalesOrder with operations to create, check, cancel or retrieve specific sales orders. The data types needed are also defined in Fig. 1. Note that in practice the component could have additional operations and might offer additional order properties. For sake of simplicity we restricted ourselves to the simple form shown in Fig. 1 which will be sufficient as example for this paper. To specify the information objects belonging to the component (on a logical level) one can use a specification data model which is realized as an UML type diagram and is part of the behavioral specification [3]. Fig. 2 displays such a model for the compo-nent SalesOrderProcessing. It shows that the component manages sales orders (with attributes id, date of order, status, customer id) and sales order items (with attributes id, quantity, product id) and that there is a one-to-many relationship between sales orders and sales order items.18 J. Ackermanncan only be called for a sales order that already exists in the component. (More pre-cise: there must exist a sales order which id equals the value of the input parameter orderId. Note that the invariant guarantees that there is at most one such sales order). context SalesOrderinv: SalesOrder.allInstances()->forAll(i1, i2 | i1 <> i2implies i1.id <> i2.id)context ISalesOrder::getOrderData(orderId: string, orderHeader: OrderHeaderData, orderItem: OrderItemData, orderStatus: Order-Status)pre: SalesOrder.allInstances()->exists(id = orderId)Fig. 3. (Partial) Behavioral specification of component SalesOrderProcessing3 Problems in Behavioral Specification of ComponentsMost component specification approaches recommend notations in formal languages since they promise a common understanding of specification results across different developers and companies. The use of formal methods, however, is not undisputed. Some authors argue that the required effort is too high and the intelligibility of the specification results is too low – for a discussion of advantages and liabilities of for-mal methods compare [14].The disadvantages of earlier formal methods are reduced by UML OCL [20]: The notation of OCL has a simple structure and is oriented towards the syntax of object-oriented programming languages. Software developers can therefore handle OCL much easier than earlier formal methods that were based on set theory and predicate logic. This is one reason why OCL is recommended by many authors for the specifica-tion of software components.Despite its advantages OCL can not solve all problems associated with the use of formal methods: One result of two case studies specifying business components [1,2] was the insight that editing OCL constraints manually is nevertheless time consuming and error-prone. Similar experiences were made by other authors that use OCL con-straints in specifications (outside the component area), e.g. [13,17]. They conclude that it takes a considerable effort to master OCL and use it effectively.It should be noted that behavioral aspects (where OCL is used) have a great impor-tance for component specifications: In the specification of a rather simple component in case study [2], for example, the behavioral aspects filled 57 (of altogether 81) pages and required a tremendous amount of work. For component specifications to be prac-tical it is therefore mandatory to simplify the authoring of OCL constraints.Formal Description of OCL Specification Patterns 194 Solution Proposal: Utilizing Specification PatternsSolution strategies to simplify OCL specifications include better tool support (to re-duce errors) and an automation of constraint editing (to reduce effort) – the latter can e.g. be based on use cases or on predefined specification patterns (compare Sect. 6). To use specification patterns seems to be particularly promising for the specifica-tion of business components: When analyzing e.g. the case study [2] one finds that 70% of all OCL constraints in this study can be backtracked to few frequently occur-ring specification patterns. Based on this observation we analyzed a number of com-ponent specifications and literature about component specification and identified nine specification patterns that often occur [4]. These specification patterns are listed in Table 1. Although the nine patterns occurred most often in the investigated material there will be other useful patterns as well and the list might be extended in future.Table 1. Behavioral specification patterns identified in [4]Constraint type Pattern nameInvariant Semantic Key AttributeInvariant Invariant for an Attribute Value of a ClassPrecondition Constraint for a Input Parameter ValuePrecondition Constraint for the Value of an Input Parameter FieldPrecondition Instance of a Class ExistsPrecondition Instance of a Class does not ExistPostcondition Instance of a Class CreatedDefinition Variable Definition for an Instance of a ClassPrecondition Constraint for an Instance Attribute for an Operation CallUnder (OCL) specification pattern we understand an abstraction of OCL constraints that are similar in intention and structure but differ in the UML model elements used. Each pattern has one or more pattern parameters(typed by elements of the UML metamodel) that act as placeholder for the actual model elements. With pattern instan-tiation we denote a specific OCL constraint that results from binding the pattern pa-rameters with actual UML model elements.As an example let us consider the pattern “Semantic Key Attribute”: It represents the situation that an attribute of a class (in the specification data model – cf. Fig. 2) plays the semantic role of a key – that is all instances of the class differ in their value of the key attribute. Pattern parameters are class and attribute and a pattern instantia-tion (for the class SalesOrder and attribute id) can be seen in the upper part of Fig. 3.Table 2. Description scheme for pattern Semantic Key Attribute [4] CharacteristicDescription Pattern nameSemantic Key Attribute Pattern parameterclass: Class; attribute: Property Restrictionsattribute is an attribute of class class Constraint typeInvariant Constraint context classConstraint body name(class).allInstances()->forAll(i1, i2 |i1 <> i2 implies (attribute) <>(attribute)) Based on the ideas of [11] we developed a description scheme that details the proper-ties of a specification pattern: pattern name, pattern parameters, restrictions for pattern use as well as type, context and body of the resulting constraint [4]. Note that the constraint body is a template showing text to be substituted in italic. The description scheme for the pattern Semantic Key Attribute is displayed in Table 2.Fig. 4. Selection screen for generating an OCL constraintThe following points connected with the exemplary pattern are worth mentioning: For sake of simplicity we presented the pattern with only one key attribute. In its regular version the pattern allows that the key is formed by one or more attributes of the class. (Note that this is the reason for not using the operator isUnique which would be rather constructed for more than one attribute.) One can also see that the patterns presented20 J. Ackermannhere are rather static – they allow for substituting UML model elements but do not allow for structural changes. For structural variations on the pattern (e.g.: the attribute id of class SalesOrderItem in Fig. 2 is only unique in the context of a specific instance of class SalesOrder ) one has to define additional patterns. We will now illustrate how such patterns can be exploited for specifications: Sup-pose the person who specifies our exemplary component is in the middle of the speci-fication process and wants to formulate the invariant from Fig. 3. He checks the li-brary of predefined specification patterns (which is part of his specification tool) and finds the pattern for a semantic key attribute (compare section 1 of Fig. 4). After se-lecting this pattern the tool will show him the pattern description and an associated template OCL constraint (showing the pattern parameters in italic). The user has to select model elements for the parameters (in section 3 of Fig. 4) – in our example the class SalesOrder and its attribute id are selected. Note that the tool can be built in such a way that it restricts the input to those model elements that are allowed for a pattern – in section 3 of Fig. 4 for instance you can see that the tool only offers the attributes of class SalesOrder for selection. After providing pattern and parameter values the user can start the generation. The tool checks the input for consistency and then generates the desired OCL constraint (compare section 4 of Fig. 5) which can beincluded into the component specification.Fig. 5. Display of the generated OCL constraintFollowing this approach has the following advantages: For the specification provider maintenance of specifications is simplified because it becomes faster, less error-prone and requires less expert OCL knowledge. For a specification user the understanding of Formal Description of OCL Specification Patterns 2122 J. Ackermannspecifications is simplified because generated constraints are uniform and are there-fore easier recognizable. Moreover, if the patterns were standardized, it would be enough to specify a pattern and the parameter values (without the generated OCL text) which would make recognition even easier.5 Technical Details of the SolutionTo realize the solution outlined in Sect. 4 we need a way to formally describe the specification patterns. Such a formal pattern description is on one hand prerequisite for a tool builder to implement corresponding constraint generators – on the other hand it might also be interesting for a user creating specifications to check if a pattern meets his expectations (although one would not generally expect that a user has the knowledge to understand the formal pattern specifications). In this section we discuss how the specification patterns can be formalized and be described such that their in-tention, structure and application become unambiguous.To do so we first show how such patterns can be formally described and applied (Sect. 5.1). After that we discuss the relationship of the solution to the UML meta-model (Sect. 5.2), argue why we have chosen it compared to other approaches (Sect.5.3) and cover some implementation aspects (Sect. 5.4).5.1 Defining OCL Pattern Functions for Specification PatternsThe basic idea how to formally describe the specification patterns is as follows: For each OCL specification pattern a specific function (called OCL pattern function) is defined. The pattern parameters are the input of the pattern function. Result of the pattern function is a generated OCL constraint which is returned and (if integrated with the specification tool) automatically added to the corresponding UML model element. The OCL pattern functions themselves are specified by OCL – from this specification one can determine the constraint properties (e.g. invariant) and its textual representation. All pattern functions are assigned as operations to a new class OclPat-tern which logically belongs to the layer of the UML metamodel (layer M2 in the four-layer metamodel hierarchy of UML [19] – compare also Sect. 5.2).This approach will now be discussed in detail for the specification pattern “Seman-tic Key Attribute” (see Sect. 4). For this pattern we define the OCL pattern function Create_Inv_SemanticKeyAttribute. Input of the function are a class cl and an attribute attr which is the key attribute of cl – both understood as UML model elements. (To avoid naming conflicts with UML metamodel elements we did not use the pattern parameter names as displayed in the tool in Fig. 4 (like class) but more technical ones (as cl) as input parameters of the pattern functions.) Result is an UML model element of type Constraint. The complete specification of this pattern function is shown in Fig. 6.Formal Description of OCL Specification Patterns 23 context OclPattern::Create_Inv_SemanticKeyAttribute(cl: Class,attr: Property): Constraint(1) pre: attr.class = cl(2) post: result.oclIsNew(3) post: space = result.context(4) post: result.specification.isKindOf(OpaqueExpression)(5) post: nguage = ‘OCL’(6) post: = ’invariant’(7) post: result.context = cl(8) post: = ‘Semantic Key Attribute’(9) post: result.specification.body = OclPattern.Multiconcat(, ‘.allInstances()->forAll( i1, i2 | i1 <> i2implies i1.’, , ‘ <> i2.’, , ‘)’) Fig. 6. Specification of pattern function OclPattern.Create_Inv_SemanticKeyAttributeThe specification of each OCL pattern function consists of three parts: •Preconditions specific for each pattern function (1)•General postconditions (2)-(5)•Postconditions specific for each pattern function (6)-(9).The function specific preconditions describe which restrictions must be fulfilled when calling the pattern function. These preconditions must assure that the actual parame-ters conform to the specification pattern. For instance defines the signature of the pattern function in Fig. 6 only, that cl is any class and attr is any property. The pre-condition (1) demands additionally that attr is an attribute that belongs to class cl.The general postconditions (2)-(5) are identical for all OCL pattern functions and represent in a way the main construction details. These postconditions (together with the functions signature) establish the following:•The return of each pattern function is a UML model element of type Constraint. •This constraint is added to the model (2) and is assigned to the model element which is the context of the constraint (3).•The attribute specification of the constraint is of type OpaqueExpression (4) and is edited in the language OCL (5). (This is in conjunction with the newest version of OCL [20] from June 2005 – earlier there was an inconsistency in the OCL 2.0 specification. Compare Fig. 29 of [20].)In difference to the general postconditions (2)-(5) the postconditions (6)-(9) vary between different pattern functions. The function specific postconditions establish the following:•(6) describes of which constraint type (e.g. invariant, pre- or postcondition) the returned constraint is. The constraint of our example is an invariant.•(7) defines the context of the constraint to be the class cl. The context of an in-variant is always some class and the context of a pre- or postcondition is the clas-sifier to which the operation belongs. Note that OCL imposes additional condi-tions depending on the constraint type. (An invariant, for instance, can only con-strain one model element.) These additional constraints are part of the OCL speci-fication [20, p. 176ff.] and will therefore not be repeated here.24 J. Ackermann•Constraint is a subtype of NamedElement and therefore has an attribute called name [21, p. 94]. This attribute is used in (8) where the constraint is assigned a name which is derived from the specification pattern (in our example the name SemanticKeyAttribute).•The textual OCL representation of a constraint can be found in the attribute body of the property specification(which is of type OpaqueExpression) of the con-straint. Postcondition (9) specifies this textual representation by combining fixed substrings (as ‘ <> i2.’) with the name of model elements which were supplied as pattern parameter values (e.g. ).Note that standard OCL contains the function concatenate which allows concatenating two substrings. In postconditions like (9) of Fig. 6 it is necessary to concatenate many substrings. Technically one could do so by repeated application of OCL concatenate but the resulting expressions were hard to read. Instead we define a help function OclPattern.Multiconcat. Input of this function is a sequence of string arguments and its result is a string which is formed by repeated concatenation of the arguments (in the order given by the sequence).constr := OclPattern.Create_Inv_SemanticKey Attribute(SalesOr-der, id)Fig. 7. Call of pattern function OclPattern.Create_Inv_SemanticKeyAttributeFig. 7 shows how the pattern function Create_Inv_SemanticKeyAttribute is called in our example from Fig. 3: As values for the pattern parameters the class SalesOrder and the property id are used. The precondition is fulfilled because id is indeed an attribute of SalesOrder. The generated constraint constr is an invariant and its textual OCL representation is (as expected) the one shown as result in Fig. 5. (Due to missing UML syntax for operation calls we use in Fig. 7 a syntax that resembles the OCL syntax for operation calls.)Other specification patterns can be described analogously. When defining OCL pat-tern functions one must be careful to select the correct UML metamodel elements for the pattern parameters (classes, properties (of classes), parameters, properties (of parameters) etc.) and to denote all relevant preconditions.One aspect to be mentioned is that some specification patterns require pattern pa-rameters with multiplicity higher than one. (In the regular version of the semantic key pattern there can be one or more attributes that form together the key of the class.) This can be solved by allowing input parameters of a pattern function to have multi-plicity greater than one ([1..*]) and by employing the OCL operator iterate to con-struct the textual OCL specification in something like a loop.5.2 Relationship with the UML MetamodelThe aim of this section is to discuss the relationship of the new class OclPattern with the UML language definition.The UML metamodel is based on a four-layer metamodel hierarchy [19, p. 17ff.]: Layer M0 consist of the run time instances of model elements as e.g. the sales orderwith id ‘1234’. Layer M1 contains the actual user model in which e.g. the class Sale-sOrder is defined. Layer M2 defines the language UML itself and contains e.g. the model element Class. Note that layers M2 and M1 are the meta-layers for layers M1 and M0, respectively. Additionally there exists the layer M3 for the Meta Object Fa-cility (MOF) which is an additional abstraction to define metamodels like UML.For the constraint patterns we defined in Sect. 5.1 a new class OclPattern. To de-cide to which layer this class logically belongs we can analyze input and output of the pattern functions: Input of an OCL pattern function are elements of a UML model (like class SalesOrder or attribute id – on layer M1) that are typed by elements of the UML metamodel (like Class or Property – on layer M2). Analogously the output is always a constraint for a UML model element and is typed by the metamodel element Constraint (on layer M2). Consequently the pattern functions operate on layer M2 and therefore the new class OclPattern logically also belongs to layer M2.On first glance it might seem desirable to integrate the class OclPattern into the UML metamodel (layer M2). The definition of UML, however, does not allow defin-ing new elements in its metamodel. Adding the class OclPattern to layer M2 would effectively mean to define a new modeling language UML’ which consists of UML and one extra class – leaving standard UML yields to many disadvantages (potential compatibility and tool problems) and is not an adequate solution.When looking more closely one finds that it is not necessary to integrate the class OclPattern that tightly into the UML metamodel because it does not change the lan-guage in the sense of introducing new model elements or changing dependencies.As a conclusion it was decided: the class OclPattern will be denoted with the stereotype «oclHelper», operates on layer M2 but stands in parallel to the UML meta-model. The class needs only to be known to the specification tool implementing the constraint generators and is of no direct relevance for model users. The class might be integrated into the UML metamodel at a later time if the UML definition allows it. Note that on a related question OCL users asked to allow user defined OCL functions (Issue 6891 of OCL FTF) which was not realized in OCL 2.0.5.3 Discussion of the SolutionIn this section we will discuss the reasons why the approach presented in Sect. 5.1 was chosen and compare it with other solution approaches that seem (at least at first glance) possible.By defining OCL pattern functions for the specification patterns it became possible to formally describe the patterns completely and quite elegantly: the pattern parame-ters can be found as function parameters and the function specification (which uses again OCL) describes the prerequisites to apply the pattern and the properties of the constraint to be generated. Moreover it is possible to actually specify that the con-straint is added to the UML model element in consideration (assuming the pattern generator is integrated with the specification tool). One big advantage is that this ap-proach only uses known specification techniques and does not require the invention of new ones. There is only one new class OclPattern that encapsulates the definition of all patterns.An alternative approach would be to use a first-hand representation for the abstract constraints before parameter binding – [5] uses this approach and calls this representa-tion constraint schema. The advantage is its explicit representation of the constraint schema. The disadvantage, however, is that constraint schemata are not defined in the UML metamodel – specifying them requires the invention of a special description technique (either outside UML or by introducing a new UML metamodel element). Therefore we decided against using this approach.UML itself offers a mechanism called Templates that allows parameterizing model elements. The following approach seems to be promising and elegant: For each pat-tern one defines a template constraint which is parameterized by the pattern parame-ters – when applying the pattern these parameters are bound to the actual model ele-ments. Unfortunately this solution is technically not possible because UML does not allow parameterizing Constraints (only Classifiers, Packages and Operations) [21, p. 600].To use UML templates nevertheless one might think about parameterizing the con-text of a constraint (which is a classifier or an operation). But this approach is rather constructed and results in many disadvantages: For each invariant pattern used there needs to be a type in the specification data model and all business types using the pattern need to be bound to it. As a result the model would become overcrowded con-tradicting the clarity guideline from the guidelines of modeling [6]. (Similar problems occur with patterns of type pre- or postcondition where template operations need to be added to the interface model.)5.4 Prototype ImplementationConstraint generators for specification patterns were implemented as a prototype (compare Fig. 4 and 5 in Sect. 4). The prototype enables to select a specification pat-tern and values for the pattern specific parameters. As far as possible pattern precondi-tions were considered when providing input for pattern parameters. All other precon-ditions must be checked after value selection. As a result the prototype generates the desired OCL constraint and displays it for the user. Planned for the future is an inte-gration of constraint generators into a component specification tool – that would per-mit to automatically add the generated constraint to the correct model element of the UML model in work.It shall be noted that the pattern parameters to be filled and the preconditions to be checked depend on the specification pattern – in the prototype these were hard coded. One could imagine something like a meta description that enables to (semi)automatically generate the constraint generator. The associated effort, however, seemed not appropriate for only nine specification patterns.6 Related WorkDue to its importance component specifications are discussed by many authors (e.g. [9,10,23,27] – for an overview compare e.g. [23]). Most current specification ap-。
人工智能原理_北京大学中国大学mooc课后章节答案期末考试题库2023年
人工智能原理_北京大学中国大学mooc课后章节答案期末考试题库2023年1.Turing Test is designed to provide what kind of satisfactory operationaldefinition?图灵测试旨在给予哪一种令人满意的操作定义?答案:machine intelligence 机器智能2.Thinking the differences between agent functions and agent programs, selectcorrect statements from following ones.考虑智能体函数与智能体程序的差异,从下列陈述中选择正确的答案。
答案:An agent program implements an agent function.一个智能体程序实现一个智能体函数。
3.There are two main kinds of formulation for 8-queens problem. Which of thefollowing one is the formulation that starts with all 8 queens on the boardand moves them around?有两种8皇后问题的形式化方式。
“初始时8个皇后都放在棋盘上,然后再进行移动”属于哪一种形式化方式?答案:Complete-state formulation 全态形式化4.What kind of knowledge will be used to describe how a problem is solved?哪种知识可用于描述如何求解问题?答案:Procedural knowledge 过程性知识5.Which of the following is used to discover general facts from trainingexamples?下列中哪个用于训练样本中发现一般的事实?答案:Inductive learning 归纳学习6.Which statement best describes the task of “classification” in machinelearning?哪一个是机器学习中“分类”任务的正确描述?答案:To assign a category to each item. 为每个项目分配一个类别。
管理学第2章关系模型与关系数据库课件
▪ 关系数据库(RDB),是采用关系模型来表示数 据的数据库。RDB的一个状态也称为一个RDB 实例。
2024/6/29
6
2.1.2 关系模型的约束及其表达
❖完整性约束(Integrity Constraints, ICs) ▪ DBMS必须能强制实施与DB模式有关的所有约 束,以限制允许存储到DB的数据,确保DB中 只有满足约束的合法数据。 ▪ ICs的主要类型包括域约束、主键约束和外键约 束,它们常被统称为基于模式的约束。
• 表行:被称为记录(record)或元组(tuple) • 表列标题:被称为属性(attribute)或字段(field) 。
2024/6/29
3
一个简单关系表的关系模式和关系实例示例(图2.1)
2024/6/29
4
其它几个重要的关系模型概念(1)
❖ 属性域 ▪ 在关系模型中,必须为每个属性指定一个域(domain)。
关系查询语言的两种属性引用方法: (1) 属性名 (2) 属性在关系模式中的位置或顺序号
2024/6/29
10
“水手值勤服务”的一个简单模式实例
2024/6/29
11
2.2.1 关系代数
❖ 关系代数由一组操作符构成。每个操作符接受1或2个关 系实例作为参数,返回一个关系实例作为结果。以下三个 方面因素,可突显关系代数在RDBMS中的重要性和地位: ▪ 它为关系模型操作提供了一个形式化的基础; ▪ 是RDBMS查询实现和优化的基础; ▪ SQL结合并保留了很多关系代数的基本概念
• r(R)={t1, t2, …, tn}
2024/6/29
5
其它几个重要的关系模型概念(2)
❖关系数据库模式 (Schema, S)
First Order Logic
Natural Deductive Rules
Natural deductive rules are logical rules accepted as being intuitively true. Universal Instantiation: If a variable is assigned a value, it will always have that value.
cons(H, T) constructs the list with H as the head and T as the tail. This is equivalent to [H|T].
[1,2,3]=[1|[2, 3]]=[1|2|3|nil]]]=cons(1, cons(2, cons(3, nil)))
Any query can be represented as a formula. To find all male patients with diagnosis code 111, use the query formula
P (interest(P) patient(P, B, male) ^ visit(P, D, 111)
−
If X = joe, X (zombie(X) eatsbrains(X)) is the same as (zombie(joe) eatsbrains(joe))
Modus Ponens: For some pair of expressions p and q, p ^ (p q q.
−
If zombie(X), (zombie(X) (eatsbrains(X))
Relational Databases
Assume there is a relational database with a patient table, visit table, and a prescription table. The patient table has fields ID, Date of Birth, and Gender. The visit table has fields ID, Visit Date, and Diagnosis Code. The prescription table has fields ID, Date, and Drug.
一带一路战略研究外文文献翻译
一带一路战略研究外文文献翻译This article focuses on the "One Belt And One Road" (OBOR) initiative。
XXX discusses the background。
objectives。
and potential impact of OBOR on the global economy and nal ns.XXX Asia。
Europe。
XXX trade and investment。
The initiative includes two main components: the Silk Road Economic Belt and the 21st Century Maritime Silk Road.The Silk Road Economic Belt is a land-based economic corridor that connects China with Central Asia。
Russia。
and Europe。
It includes the n of railways。
highways。
XXX trade and investment。
The 21st Century Maritime Silk Road is a sea-based economic corridor that connects China with Southeast Asia。
South Asia。
the Middle East。
and Africa。
It involves the development of ports。
shipping routes。
XXX.The OBOR initiative has the potential to promote economic growth and development in participating countries。
08.First order logic
15
A common mistake to avoid
Typically, is the main connective with 在需要用全称量词书写一般规则的时候, 的真值 表项是一个理想的选择
Common mistake: using as the main connective with :
First-Order Logic
Chapter 8
Last week
Logical agents apply inference to a knowledge base to derive new information and make decisions
Basic concepts of logic: — syntax(语法): formal structure of sentences — semantics(语义): truth of sentences wrt models — entailment(蕴涵): necessary truth of one sentence given another — inference(推理): deriving sentences from other sentences — soundness(可靠性): derivations produce only entailed sentences — completeness(完备性): derivations can produce all entailed sentences Forward, backward chaining are linear-time, complete for Horn clauses Resolution is complete for propositional logic
电子信息工程专业英语(第三版)词汇表
电子信息工程专业英语(第三版)词汇表Aa portion of一部分a variety of各种各样的a mass of 大量的AC abbr. Alternating Current交流电accidental adj.意外的accumulator n.累加器acquisition n.获取,采集acquisition time采集时间acquisition time采集时间activate vt.激活active adj.有源的actuator n 致动器,执行器add-on n.附件administration邮电管理局address vt.从事,忙于address generator地址产生器address pointer地址指针addressing mode寻址模式adjustment n 调整,调节ADSL abbr. Asymmetrical Digital Subscriber Loop非对称数字用户线adverse adj 不利的,相反的AFG Arbitrary Function Generator任意函数发生器aggregate v.聚集,合计AGP Accelerated Graphic Port 加速图形接口akin adj.同族的,类似的algorithm n.算法aliasing n.混叠现象alkaline adj.碱性的all in all 总而言之all of a sudden突然allocate vt.分配allocate vt.分配allow for 虑及,体谅allow for虑及,酌留alphanumeric adj.包括文字与数字的alter v.改变alternative n.选择ALU abbr Arithmetic Logic Unit算术逻辑单元aluminium n.铝ambient adj.周围的n.周围环境analogous adj.类似的analogy n.类似,类推ancillary adj.辅助的,副的anguish n 痛苦,苦恼angular frequency角频率annotation n.标注,注解antenna n.触角,天线anti-aliasing filter抗亍昆叠滤波器anti-aliasing filter抗混叠滤波器appliance n.用具,器具appliance n.用具,器县application interface 应用程序接口approach n. 方法appropriate adj.适当的approximation n.近似(值)approximation n.逼近,近似值archive vt.存档n.档案文件arena n.竞技场,舞台arena n.竞技场舞台arise from 由...引起;从...中产生arithmetic n 算数array n.阵列,数组array n.数组,阵列artificial adj.不自然的as a consequence 因此as always照常as opposed to .. 与...相反as yet到目前为止ASIC abbr. Application Specific Integrated Circuit专用集成电路ASIC Application Specific Integrated CircuitASIC Application-Specific Integrated Circuit专用集成电路assembler n 汇编器assembly language汇编语言assignment n.赋值ASSP abbr. Application Specific Standard Product专用标准器件ASSP Application-Specific Standard Parts 专用标准器件assume vt 假定asynchronous adj.异步的asynchronous adj.异步的attenuator n.衰减器audiophile n.高保真音响爱好者auditorium n.会堂,礼堂auditory system听觉系统automatic variable自动变量automotive adj.汽车的AWG Arbitrary Waveform Generator任意波形发生器B(be) known as…称作……(be) capable of…具备……的能力(be) equivalerit to相当于……,等价于……(be) proportional to与……成比例back bias 反向偏压backplane n.背叛backside n.背部,后方backward compatible向下兼容bar graph条形图bargain n.交易,协议,廉价品barrier n.隔板,势垒,阻挡层base station 基站base station基站baseband n.基带baud n 波特be concerned with…对……关心be encumbered with为……所累be mad e up of由……组成be referred to as.... 被称作...be thought of as…被认为……beam splitter 分光镜behavioral synthesis 行为综合beneficial adj.有益的,受益的Bessel filter贝塞耳滤波器biased adj.加偏压的,有偏向的bill of materials材料单BIOS abbr.Basic Input Output System基本输入输出系统bipolar adj.双极性的bit vector位向量bland adj.平淡的block diagram方框图blow up 爆炸,放大blur v 使……模糊BNC bayonet neill-concelman 同轴电缆卡环形接头boast v.夸耀Bode plot伯德图bond n. 接头Boolean variable 布尔变量boost n.升压,放大boot n.启动,引导,自举boot sector引导扇区bootstrap n. 引导程序bootstrap loader 引导装入程序brake n.刹车branch instruction分支指令brief adj.短暂的bring up 捉出,引出browse v.浏览budget n.预算budget n.预算budgetary adj.预算的buffer n 缓冲器buffer n.缓冲器,缓冲区building block 构件,模块built-in adj.内置的bulky adj.体积大的bulky adj 容量大的,体积大的bunching n.聚束bus interface总线接口bus interface总线接口by one’s (own)bootstraps 通过自己的努力by way of 经由;作为Ccable n.电缆cable modem 线缆调制解调器cable TV 有线电视cache n.高速缓存CAD Computer Aided Design 计算机辅助设计calculable adj.可计算的,能预测的calculation-intensive algorithm运算密集型算法camcorder n.便携式摄像机candid adj.非排演的,偷拍的capacitive adj.电容性的capacitor n.电容器capacity n.容量,电容capture v .记录,输入carrier wave 载波cascade n 级联cathode n.阴极cauldron n.大锅炉CB citizens'band 民用波段CCD Charge Coupled Device 电荷耦合器件CD Compact Disc 光盘cell n.细胞,蜂房,电池cellular adj.蜂窝状的characterization n.描述,表征charge pump电荷泵chat n.聊天Chebyshev Type l filter切比雪夫1型滤波器chip rate码片速率chrominance n.色度circular adj.圆形的,循环的circular adj.循环的,环形的circular buffer循环缓冲区class n.类clear-cut adj.界限分明的clever adj.精巧的,灵巧的,巧妙的cliché n 空话,套话,废话clock jitter 时钟抖动clump n.块,团CMOS abbr. Complementary Metal-Oxide-Semiconductor互补金属氧化物半导体coding theory 编码理论coexist vi.共存cold boot 冷启动collide vi.碰撞,抵触collision n.碰撞,冲突combat v.反对防止come down to归结为,涉及commute v 通勤comparable adj.可比较的,比得上的comparator n.比较器comparator n 比彰芝器compatibility n.兼容性compelling adj.强制的compiler n.编译器complex plane复平面complex-frequency variable复频率变量complicate vt使复杂,使难做,使恶化comply vi.遵守comply with同意,遵守component n 组件computing n.计算,处理concerned adj.有关的concisely adv.简明地concurrent adj.并发的concurrent process并发进程conditional adj.条件的conditioning n 调节,调整conduct v传导conductivity n. 传导性,传导率configure vt.配置,设定conflict n.冲突,抵触conformance n.顺应,一致conjugate adj.共轭的consequently adv.从而,因此consist of...由……组成consolidated adj。
First-Order-Logic
– (unlike most data structures and databases) –
☺ Propositional logic is compositional: ☺
– meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2 –
First-Order Logic
Chapter 8
2021/4/4
1
Pros and cons of propositional
logic
☺ Propositional logic is declarative
☺ Propositional logic allows partial/disjunctive/negated information
What you should know in Ch. 7
• Pros & Cons of Prop. Logics • Logical connectives rules • Ability to manipulate logic statements into
Translating the Object Constraint Language into First-order Predicate Logic
Translating the Object Constraint Language into First-order Predicate LogicBernhard Beckert,Uwe Keller,and Peter H.SchmittUniversit¨a t KarlsruheInstitut f¨u r Logik,Komplexit¨a t und DeduktionssystemeAmFasanengarten5,D-76128KarlsruheFax:+497216084211,Email:{beckert,keller,pschmitt}@a.deAbstract.In this paper,we define a translation of UML class diagramswith OCL constraints intofirst-order predicate logic.The goal is logicalreasoning about UML models.We put an emphasis on usability of the formulas resulting from the trans-lation,and we have developed optimisations and heuristics to enhancethe efficiency of the theorem proving process.The translation has been implemented as part of the KeY system,but itcan also be used stand-alone.1IntroductionOverview.The Unified Modeling Language(UML)[16]has been widely accepted as the standard object-oriented modeling language and is supported by a great number of CASE tools.The Object Constraint Language(OCL)is an integral part of UML,and was introduced to express subtleties and nuances of meaning that diagrams cannot convey by themselves.There is by now a great number of papers attributing a rigorous meaning to UML class diagrams(without OCL constraints)by translating them into a lan-guage with known semantics,for example:the CASL-LTL language(an extension of CASL)[17],the Z specification language[7]and its extension Object Z[14], the logical language of PVS[15],the Mathematical System Model(MSM)[6], EER diagrams[8],the Maude language[2].Clarification of the semantics of UML class diagrams,as provided by these pa-pers,is a necessary prerequisite for a rigorous semantics of OCL,as e.g.developed in[9,10,18]and in the draft[5].We believe that the semantics of UML/OCL, both the issues of common consent and controversial open issues,are by now un-derstood well enough to serve as a basis for further developments.This applies certainly to OCL constraints in class diagrams.The semantical status of OCL constraints in other diagram types,such as state or sequence diagrams,is less clear and we do not consider them here.We present in this paper a translation of UML/OCL intofirst-order predicate logic.Our goal is logical reasoning about UML models.The novel features of our work are that we put an emphasis on usability of the formulas resulting from the translation,we offer alternatives for the translation of model elements,where possible,we develop optimisations and heuristics to enhance the efficiency of the theorem proving process.In particular readability is a crucial issue in interactive theorem proving.The KeY Project.The work reported here is part of the KeY project(see the overview paper[1]or the web page a.de/~key for more informa-tion).The logical language used in this project is Dynamic Logic,a multi-modal extension offirst-order predicate logic specially suited to reason about prop-erties of programs.Some OCL language constructs,e.g.@pre and result in post-conditions and the iterate operation,are better translated into Dynamic Logic rather than purefirst-order logic.To keep the present account within rea-sonable bounds we restrict attention to translation intofirst-order logic only.An extensive account of how to treat the@pre operator in Dynamic Logic is given in[3].Implementation.We have implemented the translation,including some optimi-sation and heuristics.The implementation,which is written in Java,is part of the KeY system.For those who wish to use the translation in a different context, we have provided a stand-alone version that reads the UML class diagram and the OCL constraints to be translated from an XMLfile and generates a text file containing the resulting formulas.It uses the XML dialect XMI,which is a standard for the textual representation of UML diagrams.For parsing OCL constraints,we have integrated the parser component of the OCL compiler de-veloped by Hußmann et al.[12].We tried to keep the implementationflexible and it should be easy to adapt to different needs arising from other application areas,such as a new syntax for the output formulas,new optimisations,and new heuristics for choosing between several possible translations.Also,adaptations to future changes in the UML/OCL standard will not require too much effort.Both the KeY system and the stand-alone version,as well as additional doc-umentation and examples,can be downloaded from a.de/~key.To the best of our knowledge,this is thefirst implementation of such a translation.We hope that it can serve as a means helping to promote the use and application of OCL.Structure of this Paper.In Section2,we briefly review the semantical pre-requisites and describe the semantical properties of our translation.The basic translation is presented in Sections3and4,while Section5is devoted to possible optimisations that improve the readability and usability of the resultingfirst-order formulas.Section6concludes with an outlook and future extensions.All examples presented in the following refer to the class diagram shown in Figure1.2Properties of the TranslationWe start with a given UML class diagram D that is enriched by OCL con-straints C1,...,C n.Together,D and C1,...,C n describe the possible states of the system to be modeled.A system state,sometimes also called a snapshot in the UML framework,is a complete description of an instance of the modeled system.It details what objects exist(they are instances of the classes in D), gives the values of attributes for the existing objects,and defines which pairs of objects(or more general,n-tupels of objects)are instances of the associations between classes in D.Sometimes,UML object diagrams are used to describeFig.1.Example for a UML class diagram.system states or at least their non-static parts.Here,however,we use typed1first-order structures to represent system states,which allows to simplify and clarify the semantical relation between an OCL constraint and its translation intofirst-order logic(an alternative is to provide a translation of object dia-grams into correspondingfirst-order structures,which can be done easily but does not give any additional insights).Thefirst-order structures S representing system states also have a static part,consisting of the built-in data types of OCL (e.g.,Integer).The vocabularyΣ=ΣD of S,i.e.,the set of types,function,and relation symbols,is read offfrom the diagram D.Sometimes there are choices in which symbols to include inΣD:A binary association between classes A and B with multiplicity1at the B-end may give rise to the inclusion of a binary relation symbol inΣD or of a unary function symbol.To have a common platform for comparing these alternatives,we include(in this and similar cases)both symbols inΣD.The definition ofΣD follows shortly.Of course,not allΣD-structures are valid system states of D.We will say that a structure S conforms to D in case that S satisfies the diagram D and its OCL constraints C1,...,C n,i.e.,it is a possible system state according to the UML/OCL semantics[16](it is sufficient if the interpretation of the built-in OCL types satisfies a standard axiomatisation,in particular the interpretation of Integer does not have to be“the integers”but must only satisfy the standard Peano axioms).In the next two sections,we describe how to associate with a UML classdiagram D and OCL constraints C1,...,C n formulas T h D,T h C1,...,T h C n.Since new symbols are added by the translation,they are formulas over an extended signatureΣ∗=ΣD∪Σtr.Therefore,the correctness property of ourtranslation reads:For everyΣD-structure S,S conforms to D with C1,...,C n if and only if∧...∧T h C n for everyΣ∗-extension S∗of S.S∗|=T h D∧T h C1In this presentation,we ignore for the sake of conciseness partial functions. Possible extensions to overcome this restriction are discussed in Section6.Also,our translation does not handle features of the meta model—with the only exception of OCLAny and allInstances.It remains to be investigated whether reference to the meta model can be useful in the modeling of general software systems.3Translating the Class Diagram3.1Extracting a First-Order Signature from the Class DiagramIn the following,we summarise how thefirst-order signatureΣD(and,thus, the syntax of the target language of the translation)is extracted from a class diagram D.A more extensive account may be found in[19].The set of types ofΣD contains:1.A type for every class in D.Types will be denoted by the same names as thecorresponding class,starting with an upper-case letter.In OCL terminology these types are called model types.2.Integer,Real,Boolean,String.3.If T is a type,then Collection T,Set T,Bag T,Sequence T are types.Types ofthis form are called collection types.These collection types are only generated when T is not itself a collection type,i.e.,no nesting of the collection type operators is allowed.4.ΣD will furthermore the type Any which serves as the translation of theOCL type OCLAny.The subtype relation S1<D S2is defined as in[20].For each type T there will be an infinite supply of variables x:T,y:T,x i:T of type T.The set of functions and relations inΣD contains:1.For every binary association r in D with association ends e0,e1there aretwo functions inΣD,which will be referred to by the role name r i at the association end e i(i=0,1).If no role name is given,the name of the class attached to e i will be used.Function names start with a lower-case letter.Ife i is attached to class S i,then the function is of signature r i:S1−i→Set S i.In case the multiplicity2at the end e i is1,the signature is r i:S1−i→S i.If the e i-end has the stereotype≪ordered≫,then it is r i:S1−i→Sequence S i.For n-ary relations we proceed correspondingly.2.For every n-ary association r in D there is also a n-ary predicate inΣD.3.For every attribute a of a class S in D there is a function inΣD that isreferred to by the name of the attribute and has signature a:S→S r,where S r is the value type of attribute a as specified in D.If a is a class attribute (sometimes this is also called a static attribute),then a constant of type S r is added toΣD.The concrete syntax of this constant is S.a.4.For every operation c of a class S with parameters of type S 1,...,S k and result type S ′there is a function f c :S ×S 1×...×S k →S ′in ΣD .We require that c has no side effects,i.e.,it satisfies the property isQuery()[16].5.For every association class C attached to an association r ,where r associates the classes S 1and S 2,there are unary projection functions s 1:C →S 1and s 2:C →S 2in ΣD .6.All properties of the pre-defined OCL types as detailed in the standard [16]are functions or relations in ΣD .7.The symbol .=will be used to denote equality.By overloading we use the same symbol for all types.3.2Extracting Formulas from the Class DiagramThe translation T h D =( Ax ADT ∧ Ax D ∧ Constr D )of a class diagram Dconsists of three parts:Ax ADT is actually independent of D .It contains the axioms of the Abstract Data Types (ADTs)that are used to represent the built-in data types of OCL (Integer ,Boolean ,etc.),and the axioms for the ADTs Set T ,Bag T ,etc.that are used to represent the corresponding collection types of OCL.The second part Ax D is a set of axioms that depend on D but that do not express intrinsic information of D .They deal with inter-dependencies among the function and relation symbols extracted from D that reflect,for example,the symmetry of associations in UML.Example 1.Consider the association worksfor between the classes P erson and Company (Figure 1).The signature ΣD contains two function symbol and a rela-tion symbol representing this association:employer with argument type P erson and value type Set Company ,employees with argument type Company and value type Set P erson ,and the binary relation symbol worksfor with first argument of type P erson and second argument of type ompany .To restrict the interpretation of these symbols appropriately,the set Ax D contains the following axioms:∀p :P erson ∀c :Company (c ∈employer (p )↔p ∈employees (c ))∀p :P erson ∀c :Company (c ∈employer (p )↔worksfor (p,c ))∀p :P erson ∀c :Company (p ∈employees (c )↔worksfor (p,c ))The third part Constr D of T h D contains formulas representing the restric-tions on system states expressed graphically in D ,e.g.multiplicity constraints,subtyping restrictions,and others.We require in Constr D also that an abstract class is the union of its conrete subclasses and that enumerations are sets con-taining exactly their enumeration literals as elements.Instead of giving a formal definition of Constr D ,we present some typical examples:Example 2.Consider the association uses between the classes Customer and Account .The set Constr D contains the following formulas expressing the mul-tiplicity constraints attached to uses :∀c :Customer (size (accounts (c ))≥1)∀a :Account (size (accountOwner (a )).=1)4Translating the OCL Constraints4.1OverviewOCL constraints consist of an OCL expression of type Boolean and some declara-tion connecting the OCL expression to an item in the class diagram.In the case of pre-or post-conditions,the constraint is bound to an operation;invariants are bound to a class.The translation procedure for OCL constraints,therefore, cannot process OCL expressions as isolated entities but also has to take into account the diagram and the information it contains.In our basic translation described below,OCL expressions in most cases are translated into afirst-order term of the appropriate Abstract Data Type(ADT). The only exceptions are expressions of OCL type Boolean,which are usually transformed intofirst-order formulas.Thefirst-order term resp.formula that is the result of translating an OCL expression exp is denoted by⌈exp⌉.The translation procedure works by structural recursion on the expressions. When certain OCL features are translated(as described in the following sub-sections),new function or predicate symbols are introduced(they are elements of the extended signatureΣ∗)as well as axioms that constrain the interpretation of the introduced symbols according to the semantics of UML/OCL.In particular, we frequently apply the following naming technique:To represent an entity e (e.g.,a certain set of objects),a new symbol s is introduced,and axioms are added expressing that the interpretation of the symbol s is e.Note,that the new symbol may have parameters p1,...,p n,since the entity may be specified by an OCL expression that depends on the values of variables it contains(such as self).Note,that OCL allows to use some shorthand notations.We assume that constraints have been normalised to their(longer)standard form before they are translated(in our implementation we use a normalisation provided by Hußmann et al.’s OCL compiler[12]).The set Ax exp generated during the translation of an expression exp in-cludes all those axioms that are generated by the recursive translation of sub-expressions of exp—besides the axioms that stem from the translation of the “top-level”OCL feature of exp.The translation of OCL expressions is extended to OCL constraints as fol-lows.Let I be an OCL invariant of form“context C inv:b”,where C is a class in the diagram D and b is an OCL expression of type Boolean.The invariant states that,for every instance self of C existing in a system state,the property described by b holds.Accordingly,the translation T h I of the invariant I is:Axb→∀self:C⌈b⌉.Pre-and post-conditions can be translated in a similar way;only the@pre op-erator,which may occur in post-conditions,requires a special treatment(see[3] for a detailed account).4.2Translating Built-in OCL TypesTranslating Boolean Expressions.As said above,we usually translate OCL ex-pressions of type Boolean intofirst-order formulas.The boolean operators and, or,implies,not are translated into the correspondingfirst-order operators. Equality of Boolean expressions is represented by the operator↔.Translating Integer,Real,String Expressions.The OCL type Integer corresponds to an ADT Integer.As said above,the signatureΣD contains a symbol for every feature3of Integer,and Ax exp contains axioms for the ADT(the Peano axioms).Every feature of Integer is translated into the corresponding function or predicate symbol of the ADT.In the same way,the OCL types Real and String are handled with the help of ADTs Real and String.Hußmann et al.[11]have argued convincingly that the encapsulation concepts of ADTs and UML classes are very different and that UML classes can,as a consequence,not smoothly be translated into ADTs.However,their analysis applies primarily to user defined classes and does not affect the translation of basic OCL types just mentioned.Example3.Translating the OCL expressionself.age>=0and self.employer->size>=1results in the formula age(self)≥0∧size(employer(self))≥1.4.3Translating the allInstances OperatorThe OCL operator allInstances can be applied to a class(to be more pre-cise it is applied to the object of type OclType that corresponds to the class in the diagram D).It returns the set of all instances of that class in the cur-rent state.To translate this operator,we introduce a new symbol allInstances C for each class C and define⌈C.allInstances⌉=allInstances C.The follow-ing additional axiom is introduced to specify the meaning of the constant:∀o:C(o∈allInstances C).4.4Translating Collection OperatorsOverview.OCL offers a common super-type Collection(T)for the collection types Set(T),Bag(T),and Sequence(T).It does not occur in actual OCL constraints, but is used to define features that all collection types have in common(e.g., the size operator).Consequently,we provide ADTs to represent sets,bags,and sequences of all occurring types(e.g.,Set P erson,Bag P erson,Sequence P erson), but there is no such ADT to represent the collection super-type.Below,we describe the translation of the features that the collection types have in common. Translating size,count,sum,includes,append,etc.To translate these fea-tures,we use their direct counterparts in the ADTs Set T,Bag T,and Sequence T. For example,⌈c->size⌉=size(⌈c⌉)and⌈s->union(c)⌉=union(⌈s⌉,⌈c⌉). Translating Equality.We translate the equality E=s1=s2on sets s1,s2of OCL type Set(T)by expressing that they have the same elements:⌈E⌉=∀e:T(e∈⌈s1⌉↔e∈⌈s2⌉).For bags we get the formula⌈b1=b2⌉=∀e:T(count(⌈b1⌉,e).=count(⌈b2⌉,e)),and for sequences a similar translation is generated.Translating includesAll ,excludesAll .E =c1->includesAll(c2)expresses that the collection c2is a subset of c1.Thus,⌈E ⌉=∀e :T (e ∈⌈c2⌉→e ∈⌈c1⌉).excludesAll expresses that no element of c2is an element of c1and is treated similarly.Translating notEmpty ,isEmpty .The translation of c1->notEmpty is the for-mula ⌈E ⌉=∃e :T (e ∈⌈c1⌉).The operator isEmpty is treated as the negation of notEmpty .Translating forAll ,exists .The meaning of E =c->forAll(e|b)is that b evaluates to true for all possible instantiations of e with elements of the collec-tion c .Thus,⌈E ⌉=∀e :T ((e ∈⌈c ⌉)→⌈b ⌉).To translate E =c->exists(e|b)we use ⌈E ⌉=∃e :T ((e ∈⌈c ⌉)∧⌈b ⌉).Example 4.Consider the following OCL expression,which formalises “For dif-ferent objects of class Bank ,the attribute bankID has different values.”Bank.allInstances->forAll(b1,b2|not (b1=b2)implies not (b1.bankID =b2.bankID))Its translation is the following formula (a much shorter and optimised translation is given in Section 5.3):Translation:∀b 2:Bank (b 2∈allInstances Bank →∀b 1:Bank (b 1∈allInstances Bank →(¬(b 2.=b 1)→¬(bankID (b 2).=bankID (b 1)))))Additional axiom:∀b :Bank (b ∈allInstances Bank )Translating isUnique .The meaning of E =c->isUnique(e|exp)is that the evaluation of exp results in a different value for each instantiation of e with elements of c .So,⌈E ⌉=∀e 1:T ∀e 2:T ((e 1∈⌈c ⌉∧e 2∈⌈c ⌉∧⌈exp ⌉{e/e 1}∧⌈exp ⌉{e/e 2})→e 1.=e 2).4Translating sortedBy .The value of E =c->sortedBy(e|exp)is a sequence with (a)the same elements as collection c ,which are (b)ordered according to the values of the expression exp (this only makes sense if there is some order defined on the OCL type of exp ;we therefore require this type to be Integer or Real ).To translate E ,we introduce a new function symbol sortedBy E .Let p 1,...,p n be the free variables occurring in the translations ⌈c ⌉and ⌈exp ⌉of the sub-expressions—excluding the variable e .Then,the translation of E is ⌈E ⌉=sortedBy E (p 1,...,p n ).To ensure that sortedBy E has the desired inter-pretation with properties (a)and (b),the following two axioms are added to Ax E :∀p 1:T 1...∀p n :T n ∀e :T (count (⌈c ⌉,e ).=count (sortedBy E (p 1,...,p n ),e ))∀p 1:T 1...∀p n :T n ∀i,j :Integer ((1≤i ∧i ≤j ∧j ≤size (sortedBy E (p 1,...,p n )))→⌈exp ⌉{e/at (sortedBy E (p 1,...,p n ),i )}≤⌈exp ⌉{e/at (sortedBy E (p 1,...,p n ),j )})Translating select ,reject .The expression E =c->select(e|b)denotes the collection consisting of those elements of c for which b evaluates to true when e is instantiated with the element.The translation is based on introducing a new function symbol select E .Let p 1,...,p n be the free variables occurring in the translation ⌈b ⌉of the condition b excluding e .Then,the translation of E is ⌈E ⌉=select E (⌈c ⌉,p 1,...,p n ).5Three axioms are added to Ax E to specify the meaning of select E .Their form depends on whether c is a set,a bag,or a sequence.Here,we present the axioms for sets (the axioms for the other types are similar):∀p 1:T 1...∀p n :T n select E (emptySet T ,p 1,...,p n ).=emptySet T∀p 1:T 1...∀p n :T n ∀s :Set T ∀e :T (⌈b ⌉→select E (insert (s,e ),p 1,...,p n ).=insert (select E (s,p 1,...,p n ),e ))∀p 1:T 1...∀p n :T n ∀s :Set T ∀e :T (¬⌈b ⌉→select E (insert (s,e ),p 1,...,p n ).=select E (s,p 1,...,p n ))Since the reject operator is just the opposite of select ,we treat it by negating the filter condition b and then applying the above translation.Example 5.The following OCL expression formalises “There is no person who works for both company ‘BankA’and company ‘BankB’.”Person.allInstances->select(p|p.employer->exists(c1,c2| =‘BankA’and =‘BankB’))->isEmptyIts translation is the following formula (a much shorter and optimised translation is given in Section 5.3):Translation:∀p :P erson (¬(p ∈select 0(allInstances P erson )))Additional axioms:∀p :P erson (p ∈allInstances P erson )select 0(emptySet P erson ).=emptySet P erson∀s :Set P erson ∀p :P erson (∃c 1:Company (c 1∈employer (p )∧∃c 0:Company (c 0∈employer (p )∧name (c 1).=‘BankA ‘∧name (c 0).=‘BankB ‘))→select 0(insert (s,p )).=insert (select 0(s ),p ))∀s :Set P erson ∀p :P erson (¬(∃c 1:Company (c 1∈employer (p )∧∃c 0:Company (c 0∈employer (p )∧name (c 1).=‘BankA ‘∧name (c 0).=‘BankB ‘)))→select 0(insert (s,p )).=select 0(s ))Translating collect .The collect operator computes the range of an expres-sion on a certain domain (a collection).More precisely,E =c->collect(e|exp)evaluates to the bag (if c is of type set or bag)resp.the sequence (if c is of type sequence)containing for each possible instantiation of e with an element of c the corresponding value of exp .The translation of this operator is similar to thatof select ,using a new function symbol collect E .Again,let p 1,...,p n be the free variables occurring in the translation exp excluding e .The translation of E is ⌈E ⌉=collect E (⌈c ⌉,p 1,...,p n ).In OCL,when a nested collection is created,it is “flattened”,i.e.,the nesting structure is ignored and the collection justs consists of the elements of its sub-collections.This OCL feature has to be taken into account in the definition of the additional axioms that specify collect E (as above,we here only present the axioms for sets):∀p 1:T 1...∀p n :T n collect E (emptySet T ,p 1,...,p n ).=emptyBag TIf ⌈exp ⌉does not have a collection type:∀p 1:T 1...∀p n :T n ∀s :Set T ∀e :T (collect E (insert (s,e ),p 1,...,p n ).=insert (collect E (s,p 1,...,p n ),⌈exp ⌉))Otherwise:∀p 1:T 1...∀p n :T n ∀s :Set T ∀e :T (collect E (insert (s,e ),p 1,...,p n ).=union (collect E (s,p 1,...,p n ),⌈exp ⌉))Translating asSet ,asBag ,asSequence .OCL provides cast operators for chang-ing the type of a collection.To translate them,we introduce new function sym-bols.For example,to translate the expression E =c->asBag (where c is a col-lection),we introduce the symbol asBag E .Let p 1,...,p n be the free variables occurring in the translation ⌈c ⌉of c .In this case,two additional axioms are needed to formalise the meaning of asBag E :∀p 1:T 1...∀p n :T n ∀e :T ((e ∈⌈c ⌉)↔count (asBag E (p 1,...,p n ),e ).=1)∀p 1:T 1...∀p n :T n ∀e :T (count (asBag E (p 1,...,p n ),e )≤1)In exactly the same way we translate E =c->asSequence .For E =c->asSet we only need one axiom:∀p 1:T 1...∀p n :T n ∀e :T ((e ∈⌈c ⌉)↔e ∈asSet E (p 1,...,p n ))Example 6.The following OCL expression (as the body of an invariant for class P erson )formalises “The collection of companies a person works for and the col-lection of companies a person has a contract of employment with are identical.”self.contract->collect(c|c.employer)->asSet =self.employer Its translation is the following formula (a much shorter and optimised translation is given in Section 5.3):Translation:∀c :Company (c ∈asSet 0(self )↔c ∈employer (self ))Additional axioms:∀p :P erson ∀c :Company (c ∈collect 0(contract (p ))↔c ∈asSet 0(p ))collect 0(emptySet Contract ).=emptyBag Contract∀s :Set Contract ∀l :Contract (collect 0(insert (s,l )).=insert (collect 0(s ),employer (l )))4.5Translating Other Constructs of OCLTranslating oclIsKindOf ,oclIsTypeOf .These operators allow to check which type the value of an expression exp has.The translation of exp.oclIsKindOf(T)is ∃x :T x .=⌈exp ⌉.The operator oclIsTypeOf can be expressed by oclIsKindOf using the sub-type relation extracted from the diagram D .Translating oclAsType .To translate the cast operator oclAsType ,we introduce a new function symbol oclAsT ype T 1,T 2:T1→T2for every pair T1,T2where T2is a sub-type of T1,and we define ⌈o.oclAsType(T2)⌉=oclAsT ype T 1,T 2(⌈o ⌉)(where o is of type T1).The additional axioms specifying these symbols are of the form ∀x :T 2(oclAsT ype T 1,T 2(x ).=x ).Translating let .The let construct is an abbreviation mechanism that allows to use the same expression multiply.The value of E =let v:T =e1in e2is that of e2,where all occurrences of v are replaced by e1during the evaluation.We handle this construct by introducing a new function symbol let e1.Let p 1,...,p n be the free variables in the translation of e1.Then,the translation of E is ⌈E ⌉=⌈e2⌉{v/let e1(p 1,...,p n )}.The additional axiom specifying the meaning of the new symbol is ∀p 1:T 1...∀p n :T n (let e1(p 1,...,p n ).=⌈e1⌉).Translating if-then-else .The value of E =if b then e1else e2is that of e1if b evaluates to true and that of e2otherwise (the expressions e1and e2do not have to be of type Boolean ).For the translation of E ,we introduce a new function symbol if E .Let p 1,...,p n be the free variables occurring in the translations ⌈b ⌉,⌈e1⌉,⌈e2⌉of the sub-expressions.We define the translation of E to be ⌈E ⌉=if E (p 1,...,p n )and add the following two axioms to Ax E :∀p 1:T 1...∀p n :T n (⌈b ⌉→if E (p 1,...,p n ).=⌈e1⌉)∀p 1:T 1...∀p n :T n (¬⌈b ⌉→if E (p 1,...,p n ).=⌈e2⌉)Translating Variables and Literals.The translation of an OCL variable v ,in-cluding self ,is a first-order variable with the same name,i.e.,⌈v ⌉=v .OCL literals of type Boolean ,Integer ,Real ,or String are translated into a term over the corresponding ADT.To translate literals of collection types,in case they enumerate the elements of a collection,we construct a term over the ADT Set T (resp.Bag T or Sequence T ).For example,⌈Set{1,2,3}⌉=insert (insert (insert (emptySet Integer ,1),2),3).To translate collection literals that specify a range of elements,such as the ex-pression E =Set{e1..e2},we introduce a new function symbol set E and define ⌈E ⌉=set E (p 1,...,p n )(where p 1,...,p n are the free variables occurring in the translations of the bounds e1and e2).The additional axiom specifying set E is∀p 1:T 1...∀p n :T n ∀i :T (i ∈set E (p 1,...,p n )↔(⌈e1⌉≤i ∧i ≤⌈e2⌉)).For bags and sequences,the translation is similar.However,additional axioms are needed to express that (a)every element in the range occurs exactly once in the result and (b)for sequences,that the elements are ordered.Example 7.The following OCL expression (read as an invariant for Customer )formalises “A customer’s favourite companies are ordered according to their stock price.”Sequence {1..self.favourites->size}->forAll(i,j|j >=i impliesself.favourites->at(i).stockPrice()>=self.favourites->at(j).stockPrice())。
The first-order theory of ordering constraints over feature trees
Discrete Mathematics and Theoretical Computer Science4,2001,193–234The First-Order Theory ofOrdering Constraints over FeatureT reesMartin Müller1and Joachim Niehren1and Ralf Treinen21Programming Systems Lab,Universität des Saarlandes,Saarbrücken,Germany. http://www.ps.uni-sb.de/~mmueller,http://www.ps.uni-sb.de/~niehren 2Laboratoire de Recherche en Informatique,UniversitéParis-Sud,Orsay,France. http://www.lri.fr/~treinenreceived April19,1999,revised February2001,accepted Aug15,2001.1Introduction194 2Ordering Constraints196 3Expressiveness of the First-Order Theory197 4Undecidability Results199 5Entailment with Existential Quantifiers203 6Correctness of the Entailment Test217 7Completeness of the Entailment Test2261365–8050c2001Maison de l’Informatique et des Mathématiques Discrètes(MIMD),Paris,France194Martin Müller and Joachim Niehren and Ralf Treinen 1IntroductionFeature constraints have been used for describing records in constraint programming[1, 30,31,36]and record-like structures in computational linguistics[14,12,23,26].Feature constraints also occur naturally in type inference for programming languages with object types or record types[22,5,24].Following[2,4,3],we consider feature constraints as predicate logic formulas interpreted in the structure of feature trees.A feature tree is a tree with unordered edges labeled by features and with possibly labeled nodes.Features are functional in that the features label-ing the edges departing from the same node must be pairwise different.The structure of feature trees gives rise to an ordering in a very natural way which is called weak subsump-tion ordering in[7].Consider the following example where an unlabeled node is indicated as:Here,the left treeτ1is said to weakly subsume the right treeτ2sinceτ1has fewer edges and node labels thanτ2.In other words,every positive assertion about the presence of labels or features that holds forτ1also holds forτ2.In general,a treeτ1weakly subsumes a treeτ2, writtenτ1τ2,ifevery word of features in the tree domain ofτ1belongs to the tree domain ofτ2and the(partial)labeling function ofτ1is contained in the labeling function ofτ2. We consider the system FT of ordering constraints over feature trees[18,19,17].Its constraintsϕare given by the following abstract syntaxϕ::x x x f x a xϕϕwhere f denotes a feature symbol and a a label symbol.The constraints of FT are inter-preted in the structure of feature trees with the weak subsumption ordering.We distinguish two cases,the structure offinite feature trees and the structure of possibly infinite feature trees.A constraint x x holds if the denotation of x weakly subsumes the denotation of x, x f x is valid if the denotation of x has an edge at the root that is labeled with the feature f and leads to the denotation of x,and a x means that the root of the denotation of x is labeled with a.The constraint system FT is an extension of the well-investigated constraint system FT[2, 4],which provides for equality constraints x y rather than more general ordering con-straints x y.The system FT can be seen as a sub-system of FT since x y can be expressed as x y y x thanks to anti-symmetry of the weak subsumption order.The fullfirst-order theory of FT is decidable[4]and has non-elementary complexity[37]. The decidability question for thefirst-order theory of FT has been raised in[17].There, two indications in favour of decidability have been formulated:its analogy to FT and its relationship to second-order monadic logic.However,we show in this paper that the thefirst-order theory of FT is undecidable.Our result holds in the structure of possibly infinite feature trees and,more surprisingly,even in the structure offinite feature trees. Our proof is based on an encoding of the Post Correspondence Problem using a technique of[33].Once the undecidability of thefirst-order theory of FT is settled,it remains to distin-guish decidable fragments and their complexity.It is well-known that the satisfiabilityThe First-Order Theory of Ordering Constraints over Feature Trees195FTfinn3[18]Entailment w/o quantifiers n3[18]Co-NP hard[17]PSPACE complete[here]Full theory undecidable[here]Fig.1:Fragments of thefirst-order theories of FT and FTfinproblem of FT,its entailment problemϕϕ,and its entailment problem with existential quantifiersϕx1x nϕcan be solved in quasi-linear time[31].The investigation of ordering constraints was initiated by Dörre[7]who gave an O n5-algorithm for deciding satisfiability of FT-constraints.This result was improved to O n3in[18],where also the entailment problem of FT concerning quantifier-free judgmentsϕϕwas shown decidable in cubic time.The next step towards larger fragments of the theory of FT was to consider entailment judgments with existential quantificationϕx1x nϕwhich are equivalent to unsatisfiability judgmentsϕx1x nϕwith quantification below nega-tion.As shown in[17],this problem is decidable,coNP-hard in case offinite trees,and PSPACE-hard in case of arbitrary trees.Decidability is proved by reduction to(weak)sec-ond order monadic logic(W)S2S.In afirst reduction step,it is shown how to substitute the structure of feature trees by the related structure of so-called sufficiently labeled fea-ture trees.We note that this step cannot be generalized to arbritraryfirst-order formulas beyond entailment with existential quantifiers.Since the fullfirst-order theory of ordering constraints over sufficiently labeled(finite)feature trees can easily be encoded in(weak) second order monadic logic,decidability of entailment of FT with existential quantifiers follows from the classical results on(W)S2S[32,25].This paper contributes the exact complexity of the entailment problem of FT with existen-tial quantification.We prove PSPACE-completeness,both in the structure offinite trees and in the structure of possibly infinite trees.This result is obtained by reducing the entailment problem of FT with existential quantifiers to the inclusion problem of non-deterministic finite automata(NFA),and vice versa.Our reduction of entailment is based on the fol-lowing idea:Given an existential formula196Martin Müller and Joachim Niehren and Ralf Treinen feature trees and all feature structures).Following[8],ordering constraints interpreted with respect to the subsumption(resp.weak subsumption)ordering of arbitrary feature algebras are called subsumption(resp.weak subsumption)constraints.Syntactically,subsumption constraints,weak subsumption constraints,and FT constraints coincide but semanticallythey differ.As proved in[8],the satisfiability problem of subsumption constraints is un-decidable.The satisfiability problem of weak subsumption constraints is equivalent to the satisfiability problem of FT constraints[7,18]and hence decidable in cubic time. Structure of the Paper.Section2reviews the definitions of feature trees and weak sub-sumption constraints.We demonstrate the expressivity of the constraint language in Sec-tion3and introduce some formulas used in later sections.Undecidability of thefirst-order theory of weak subsumption constraints is shown in Section4.Finally,we show the entail-ment problem of existentially quantified constraints to be PSPACE-complete in Section5. We prove the correctness of our algorithm in Section6and its completeness in Section7.A short version of this paper has been published as[21].2Ordering ConstraintsThe constraint system FT is defined by a set of constraints,the structure of feature trees, and an interpretation of constraints over feature trees.We assume an infinite set V of variables ranged over by x y z,a set F of at least two features ranged over by f g and a set L of labels ranged over by a b.2.1Feature T reesA pathπis a word of features.The empty path is denoted byεand the free-monoid concatenation of pathsπandπasππ.We haveεππεπ.A pathπis called a prefix ofπifπππfor some pathπ.A tree domain is a non-empty prefix closed set of paths.A feature treeτis a pair D L consisting of a tree domain D and a partial function L: D L that we call labeling function ofτ.Given a feature treeτ,we write Dτfor its tree domain and Lτfor its labeling function.For instance,τ0εf f ais a feature tree with domain Dτ0εf and Lτf a.A feature treeτ0a fisfinite if its tree domain isfinite,and infinite otherwise.A node ofτis anelement of Dτ.A nodeπofτis labeled with a ifπa Lτ.A node ofτis unlabeled if it is not labeled with any a.The root ofτis the nodeε.The root label ofτis Lτε,and f F is a root feature ofτif f Dτ.A feature treeτis fully labeled if Lτis a total function with domain Dτ.Given a treeτwithπDτ,we write asτπthe subtree ofτat pathπ;formally DτππππDτand Lτππaππa Lτ.2.2Syntax and SemanticsAn FT constraintϕis defined by the abstract syntaxϕ::x y a x x f yϕ1ϕ2where a L and f F.In other words,an FT constraint is a conjunction of basic con-straints which are either ordering constraints x y,labeling constraints a x,or selection constraints x f y.We define the structure FT over feature trees in which we interpret FT constraints.ItsThe First-Order Theory of Ordering Constraints over Feature Trees197 universe consists of the set of all feature trees.The constraints are interpreted as follows:τ1τ2iff Dτ1Dτ2and Lτ1Lτ2τ1fτ2iff Dτ2πfπDτ1and Lτ2πa fπa Lτ1aτiffεa LτThe substructure of FT whose universe contains only thefinite trees is denoted by FTfin. We will often use the following decomposition property without further mention:Proposition2.1Ifτ1τ2andτ1fτ1andτ2fτ2thenτ1τ2.2.3First-Order FormulasIf not specified otherwise,a formula is said to be valid(satisfiable)if it is valid(satisfiable) both in FT and FTfin.Our intention here is to treat both cases simultaneously and to note a distinction when needed only.LetΦandΦbefirst-order formulas built from FT constraints with the usualfirst-order connectives and quantifiers.We say thatΦentailsΦ, writtenΦΦ,ifΦΦis valid,and thatΦis equivalent toΦifΦΦis valid.We denote with VΦthe set of variables occurring free inΦ,and with FΦand LΦthe set of features and labels occurring inΦ.3Expressiveness of the First-Order TheoryIn this section we introduce some abbreviations of formulas needed in Section4.We use the usual abbreviations for ordering constraints,for instance we write x y for x y,x y for x y x y,x y for y x and x y z for x y y z.3.1Minimal and Maximal ValuesWe can construct,for any formulaϕ,formulasµxϕandνxϕexpressing that x is minimal (maximal)with the propertyϕ:µxϕ:ϕyϕy x y xνxϕ:ϕyϕy x y xHere,y is a fresh variable not occurring inϕ,andϕy x denotes the formula where every free occurrence of x is replaced by y.Typically,x occurs free inϕbut this is not required. Note that,in contrast to x and x,µx andνx are no variable binders that restrict the scope of the variable x;hence x is free inµxϕand inνxϕif it is free inϕ.The formulaµxϕexpresses that x denotes a minimal tree satisfyingϕ,which is not necas-sarily a smallest tree with this property.In analogy,νxϕexpresses that x denotes a maximal but not necessary greatest tree satisfyingϕ.Example1The sentence xµx true is valid in FT and in FTfin(there even exists a smallest tree,namelyε.The formulaνx true is not satisfiable in FTfin but is satisfied in FT by any fully labeled tree with domain F.The difference between smallest and minimal trees is important for the formula atom x which expresses that x denotes an atom in the lattice-theoretic sense,i.e.that it is a tree strictly greater than the smallest treeεbut with minimal distance(one feature or one label more):one-dist x y:µy x yatom y:xµx true one-dist x y198Martin Müller and Joachim Niehren and Ralf Treinen Example2The formulaµx x0x x1x is satisfied in FT by01,that is the full binary and everywhere unlabeled tree,and is not satisfiable in FTfin since FTfin contains no infinite trees.3.2Label RestrictionsThe formula x y reads x and y are consistent,that is wheneverπa Lτandπa Lτthen a a:x y:z x z y zFor any label a L we write x a to express that the root of x is either unlabeled or labeled with a:x a:y x y a yThe following formula expresses that the root of a tree is unlabeled:not-root-labeled x:x a x bwhere a and b are two arbitrary different label symbols.We obtain afirst-class status of labels by encoding a label a as the feature treeεεa.label-atom x:atom x not-root-labeled xWe can now express that x and y either have the same root label or are both unlabeled at the root by:same-root-label x y:z label-atom z x z y z3.3Arity RestrictionsWe can simulate afirst-class status of feature symbols by encoding a feature f by the tree εf/0.feature-atom x:atom x not-root-labeled xWe can express that y has at least all the root features of x byz feature-atom z z x z yThe following formula expresses that x has exactly the root features f1f n: x f1f n:x1x n x f1x1x f n x ny y f1x1y f n x n same-root-label x y x yThese so-called arity constraints have been introduced in[31].A decidable feature logic where feature symbols havefirst class status has been investigated in[34].3.4Inductive PropertiesWe start this section by a demonstration of the expressivity of FT and show that we can express in FT“inductive properties”of trees,that is properties that require an inductive construction(for instance an automaton)to define.We conclude the section by the defini-tion of the predicate string-c x that we will need in the undecidabability proof of Section4. In the case of infinite trees it is in fact quite simple to express“inductive properties”of a tree.For instance,we can express that the domain of x contains the set01byy y0y y1y y xThe First-Order Theory of Ordering Constraints over Feature Trees199 The following formula says that the tree denoted by x has domain01and that exactely one of its nodes is labeled with a whereas all its remaining nodes are unlabeled: a-singleton x:y zµy y0y y1y not-root-labeled yµz z0z z1z a zy x z one-dist y xIf a-singleton x is satisfied then y denotes the complete binary,everywhere unlabeled tree (with domain01),and z denotes the complete binary,everywhere a-labeled tree.The formula b-singleton is defined analogously.We can now express that x denotes a tree with domain01and that all its nodes are labeled with either a or b by:µx y z a-singleton y b-singleton z y z y x z xThe idea behind this formula is the following:an a-singleton and a b-singleton are in-consistent iff they have their label at the same position.Hence,the formula says that 01D x and every node of x which is reachable via a01-path is either labeled with a or with b.The minimality of x yields D x01.In case offinite trees we have to use another trick(which works also in case of infinite trees).The next formula is crucial for our undecidability proof.A treeτsatisfies this formula iffεc Dτc and all its nodes are unlabeled:string-c x:x c not-root-labeled x y x c y y xThe correctness of this definition of string-c x with respect to the above stated semantics follows from the following lemma where we write c n for the word c c consisting of n letters c.Lemma3.1The formula y x c y y x is satisfied byτiff c Dτand for all k m0, whenever c m k Dτthenτc m kτc mProof.Letτcτandττ.Obviously,c Dτ.The inequality follows by induction: For any m,if c m Dτthenτc mτc m.Furthermore,for any k with c m k1Dτand τc m kτc m we have thatτc m k1τc c m kτc m kτc m kτc mFor the other direction,since c Dτthere is aτsuch thatτcτ.From the above inequality we get by setting m0and k1thatττc1τc0τετ4Undecidability ResultsTheorem4.1Thefirst-order theories of FTfin and of FT are undecidable.The result holds for arbitrary(even empty)L and for F of cardinality 2.For the sake of clarity we use in the proof distinct label symbols a b e and pairwise distinct feature sym-bols s c p l r.We prove Theorem4.1by reduction of the Post Correspondence Problem (PCP).The choice of PCP is motivated by the fact that our proof works by simulation of an iterative construction,and that PCP uses a technically very simple iteration.This is200Martin Müller and Joachim Niehren and Ralf Treinen different in nature to the technique in [8]for the proof of undecidability of the satisfiabil-ity of strong subsumption constraints.There,Thue-systems could be used by exploiting a correspondence between word equations and the algebraic properties of feature structures.See [33]for a discussion of the proof technique employed in this chapter.An instance of PCP is a finite sequence P p i q i i 1m of pairs of words from a b .Such an instance is solvable if there is a nonempty sequence i 1i n ,1i j m ,such that p i 1p i n q i 1q i n .According to a classical result due to Post,it is undecidable whether an instance of the PCP is solvable.In the following,let Pp i q i i 1m be a fixed instance of PCP.We say that a pair v w is P-constructed from a pair of words v w if,for some j ,v p j v and w q j w .We say that a set X of pairs of words is P-constructed if every pair in X is either εεor is P -constructed from some other pair in X .To encode solvability of P into the theory of FT fin ,resp.FT ,we employ the following equivalent definition of solvability:Proposition 4.2P is solvable iff there is a P-constructed set X of pairs of words containing a pair w w with w ε.4.1Words and T reesGiven a word wa b over labels a b L fixed above we denote its length by w and for a natural number 1j w we write w j for the j ’th letter of w .There is an obvious one-to-one encoding function γfrom words w a b to feature trees for which we use the feature symbol s and label e that we also fixed above:γw D w L w where D w εs s w ,L w s j w j for 0j w 1,and L w s w e (see Figure 2(a)).We define a left-inverse function ¯γ,that is ¯γγw w ,from feature trees to (possibly infinite)words in a b ωas follows:If τdoes not have root feature s ,or if its root isunlabeled or has label different from a and from b then ¯γτε.Otherwise let τbe such that τs τ.We define ¯γτa ¯γτif τhas root label a ,and ¯γτb ¯γτif τhas root label b .To express that y denotes the fixed word πappended with the denotation of x ,we define for any πa b a formula app πx y ,such that1.if app πττthen π¯γτ¯γτ2.app πγw γπw is validfor all words w and feature trees ττ,by induction on π:app εx y :x yapp a πx y:a y z y s z app πx zapp b πx y :b y z y s z app πx zFurthermore,we define eps x ,expressing that x denotes a tree τwith ¯γτε,byeps x :y x s y a x b xFinally,the following formula expresses that x denotes a finite string:finite x :y y s y y xIn case of FT fin this formula is,of course,equivalent to true .The First-Order Theory of Ordering Constraints over Feature Trees201 asase(a)The string abaa.pl rτl1τr1cpl rτl2τr2c202Martin Müller and Joachim Niehren and Ralf Treinen ccFig.3:A possible value for x such that one-branch x x,where x is as in Figure2(b). Since we know already how to encode words as trees,we now have to define an appropriate encoding of an arbitrary set of pairs of trees as a feature tree,together with a corresponding formula in.The representation of a sequenceτl iτr i i1n is given in Figure2(b).We define,for any formulaϕ,a formulaµ!xϕexpressing that x denotes the smallest element satisfyingϕ.This formula is stronger thanµxϕin that it requires the existence of a smallest tree satisfyingϕin addition:µ!xϕ:ϕyϕy x x yIf x denotes a tree as given in Figure2(b),then the formula one-branch x x given below expresses that x denotes a tree as given in Figure3.one-branch x x:x cνx c string-c x c x c xx c x xνx zµ!z x c z xIn this formula,x is smaller than x but is strictly greater than the c-spine x c of x.The tree x can have only one of the p-edges of x since the set of trees between x c and x must have a smallest element.By the maximality of x,the tree x contains x c plus exactly one of the subtrees of x starting with a p-edge(see Figure3).The following formula selectτlτrσ,whereσis as in Figure3,expresses thatτl is the treeτl i andτr is the treeτr i:select y l y r x:xµx x x x x c x x xz x p z z l y l z r y rFrom a treeσas given in Figure3,we get the treeσ(denoted by x)containing at all nodes c j with j i a pairτl jτr j such thatτl iτl j andτr iτr j(by Lemma3.1).By the minimality ofσwe get thatτl iτl j andτr iτr j for all j i,hence in particular for j0(see Figure4).Combination of the two formulas yieldsin y l y r x:x one-branch x x select y l y r xNow,it is easy to verify the conditions announced at the beginning of the proof.pl r τl iτr icpl rτl iτr icFig.4:The value of x in the formula select y l y r x where x is as in Figure3.Note that this proof did not make use of the fact that the feature trees considered here are partial.The proof of Theorem4.1transfers immediately to the structures of completelylabeled trees(both in the case offinite and of arbitrary trees),where a tree D L is called completely labeled if L is a total function with domain D.In this case,the trees depicted inFigures2(b),3and4have to be completed by giving some label to the nodes.5Entailment with Existential QuantifiersIn[17]it is shown that the entailment problem of FT with existential quantifiersϕxϕis PSPACE-complete for both structures FT and FTfin.In Section5.3we modify the PSPACE-hardness proof given in[17]for the case of infi-nite trees such that it proves PSPACE-hardness for both cases(Theorem5.2).In particu-lar,we show that we can encode the Kleene-star operator without need for infinite trees. Containment in PSPACE is shown(Theorem5.9)by reducing in polynomial time the en-tailment problem to an inclusion problem between the languages accepted by nondeter-ministicfinite state automata(NFA).Language equivalence for NFA(and hence inclusion, since A B B A B)is known to be PSPACE-complete if the alphabet contains at least two distinct symbols[9].5.1Path ConstraintsWe characterize existential FT formulasy y z z x yy za z x?f g afgy y z z x y z y a zfgFig.5:Graphical Presentation of Example4The semantics of path constraints is given by extension of the structure FT through the following predicates,which are defined on basis of the subtree selection functionτπin-troduced above.τπiffπDτaτπiffπa Lττ?πa iffπDτimpliesτπaτ?πτ?πiffπDτandπDτimplyτπτπτ?πτ?πiffπDτandπDτimplyτπτπIn the Section5.2,we use path constraints for presenting typical examples of entailment judgements.Path constraints are also helpful for proving PSPACE-hardness in Section5.3. In Section5.5we will construct afinite automaton that accepts all path constraintsψen-tailed byxy xxyzb xc zf g fg x ?f gaFig.6:Graphical Presentation of Example 5uxvyuvyxyf ffFig.7:Graphical Representation of Example 6holds.In other words,if αis a solution of the constraint displayed on the left hand side and if f g D αx then the subtree of αx at f g is compatible with any label a,and hence is unlabeled.Example 6(see Figure 7)The following situation illustrates a non-trivial example for entailment of selection constraints without existential quantifiers.yuu f uuxxv v f vvyx f yThe right-hand side x f y is equivalent to the conjunction y ?εx ?f x fx ?f y ?εof path constraints which are entailed by the first and second part of the left-hand side,respectively.5.3Entailment is PSP ACE-hardIn this section we show how the PSPACE completeness proof of [17]can be modified such that it applies to the structure of finite feature trees as well.The formulas used in the earlier proof require the existence x πof all paths πin some regular language R ;every solution of the formula for an infinite language R has to map x to an infinite pared to this earlier proof,the trick is here to use conditional path constraints which may constrain infinitely many paths without requiring their existence.Theorem 5.2The entailment problem for existentially quantified FT -constraints is PSPACE-hard in both the finite and the infinite tree case.This follows from Proposition 5.6(see below),which claims a polynomial reduction of the inclusion problem between regular languages over the alphabet F to an entailment problem between two existential FT formulas.Notice that we have assumed F to contain at least two features.Our PSPACE-hardness proof is based on the fact that a satisfiable ordering constraint ϕmay entail an infinite conjunction of path constraints,even in case of finite trees:Example 71.for all n :x f y y x a xx ?f na.2.for all n m :x f y y xx ?f mnx ?f n .3.for all πf g:x xx f xx g xx ?πx ?ε.For this reason the entailment problem for FT findoes not necessarily reduce to an inclusion problem between finite regular languages (which is decidable in coNP [9]).We fix a finite subset F F of features and consider regular expressions of the following form:R ::εfRR 1R 2R 1R 2where fFFor encoding a regular expression R the main idea is to define an existential formula Θx R y for fresh variables x y such that Θx R y is equivalent to πL R x ?πy ?ε.Once this is done,it will follow immediately that L RL R iff Θx R y Θx R y .It is not obvious,however,how to define such a formula.The reader might notice,that a naive definition of Θx R y yields some unintended compatibility relations to be entailed too.Hence,we have to refine our main idea.We define the formula com F x expressing that all subtrees of x reachable via an F -path are compatible with each other,i.e.they have a common upper bound:com F x :y x yf Fy y f yyyLemma 5.3(Comon upper bound)com F xy πF x ?πy ?ε.For encoding a regular expression R ,a refined idea is to define an existential formula Θx R y such that Θx R y is equivalent to com F x πL R x ?πy ?ε.We de-fine for all regular expressions R over F and variables x and y ,the existential formulas Θx R y and Θx R y recursively as follows.Θx R y com F xΘx R yΘx εy x y Θx f yz x z z f yΘx R 1R 2y Θx R 1y Θx R 2y Θx R 1R 2y z Θx R 1z Θz R 2y Θx R yz x zΘz R z z yApparently,Θx R y has size linear in the size of R .Lemma 5.4For all regular expressions Rcom F xΘx R yπL Rx ?πy ?εProof.We proceed by induction on R .ε:Θx εyx yx ?εy ?επL εx ?πy ?ε.f :Θx f yz x z z f y x ?f y ?επL fx ?πy ?ε.R 1R 2:By induction hypothesis com F x entails the equivalences Θx R 1yπL R 1x ?πy ?εand Θx R 2y πL R 2x ?πy ?ε.Hence,com F x en-tails Θx R 1R 2y πL R 1R 2x ?πy ?εalso.R 1R 2:By definition Θx R 1R 2y z Θx R 1z com F z Θz R 2y .By in-duction hypothesis,com F x entails Θx R 1z π1L R 1x ?π1z ?εandcom F z entails Θz R 2yπ2L R 2z ?π2y ?ε.Hence,com F x entails thatΘx R 1R 2y is equivalent to (1):zπ1L R 1x ?π1z ?εcom F zπ2L R 2z ?π2y ?ε(1)It remains to show that com F x entails the equivalence between (1)and (2):πL R 1R 2x ?πy ?ε(2)Since (1)obviously entails (2),it is sufficient to prove the validity of com F x 21.Let αbe an FT -valuation which satisfies both com F x and (2).We define a tree τsuch that αz τsatisfies the matrix of (1).For this definition we use a least upper bound operator on feature trees denoted by :τπ1L R 1D αxαx π1Since αsolves com F x there exists an upper bound of αx ππF as stated by Lemma 5.3and thus the least upper bound τexists.We next demonstrate that αz τsatisfies the matrix of (1).The definition of τyields αx π1τfor all π1L R 1D αx ,i.e.the variable assignment αz τsatisfies the first conjunc-tion in (1).From com F αx it follows that com F τholds,i.e.αz τsatis-fies com F z .Furthermore,all π2D τsatisfy:τπ2π1L R 1D αx αx π1π2.Since αis a solution of (2),αx π1π2αy is satisfied by all π2L R 2.Thus τπ2αy is valid for all π2L R 2,i.e.αz τsatisfies π2L R 2z ?π2y ?ε,the remaining conjunct in (1).R :By definition Θx R y z com F z x z Θz R z z y .The inductionassumption yields that com F z entails Θz R z πL R z ?πz ?ε.Hence,com F x entails that Θx R y is equivalent to (3):z com F zx zπL Rz ?πz ?εz y(3)It remains to show that com F z entails the equivalence between (3)and (4):πL Rx ?πy ?ε(4)In order to show the non-trivial implication,we assume an FT -valuation αwhich satisfies both com F x and (4).We define a tree τsuch that αz τsatisfies the matrix of (3)as follows:τπL RD αxαx πNote that τis well-defined for the same reason as in the preceeding case.Our assump-tions on the choice of αyields:com F τ,αx τ(since εL R )and ταy .In order to show that αz τis a solution of (3)it remains to prove τπτfor all πL R D τ:τππL RD αxαx πππL RD αxαx πτ。
On the unusual effectiveness of Logic in computer science
On the Unusual Effectiveness of Logic in Computer ScienceJoseph Y.Halpern Robert Harper Neil Immerman Phokion G.KolaitisMoshe Y.Vardi Victor VianuJanuary20011Introduction and OverviewIn1960,E.P.Wigner,a joint winner of the1963Nobel Prize for Physics,published a paper titled On the Un-reasonable Effectiveness of Mathematics in the Natural Sciences[Wig60].This paper can be construed as an examination and affirmation of Galileo’s tenet that“The book of nature is written in the language of mathe-matics”.To this effect,Wigner presented a large number of examples that demonstrate the effectiveness of mathematics in accurately describing physical phenomena.Wigner viewed these examples as illustrations of what he called the empirical law of epistemology,which asserts that the mathematical formulation of the laws of nature is both appropriate and accurate,and that mathematics is actually the correct language for formulating the laws of nature.At the same time,Wigner pointed out that the reasons for the success of mathematics in the natural sciences are not completely understood;in fact,he went as far as asserting that“...the enormous usefulness of mathematics in the natural sciences is something bordering on the mysterious and there is no rational explanation for it.”In1980,R.W.Hamming,winner of the1968ACM Turing Award for Computer Science,published a follow-up article,titled The Unreasonable Effectiveness of Mathematics[Ham80].In this article,Hamming provided further examples manifesting the effectiveness of mathematics in the natural sciences.Moreover, he attempted to answer the“implied question”in Wigner’s article:“Why is mathematics so unreasonably effective?”Although Hamming offered several partial explanations,at the end he concluded that on balance this question remains“essentially unanswered”.Since the time of the publication of Wigner’s article,computer science has undergone a rapid,wide-ranging,and far-reaching development.Just as in the natural sciences,mathematics has been highly effective in computer science.In particular,several areas of mathematics,including linear algebra,number theory, probability theory,graph theory,and combinatorics,have been instrumental in the development of computer science.Unlike the natural sciences,however,computer science has also benefitted from an extensive and continuous interaction with logic.As a matter of fact,logic has turned out to be significantly more effective in computer science than it has been in mathematics.This is quite remarkable,especially since much of the impetus for the development of logic during the past one hundred years came from mathematics.This paper summarizes a symposium,by the same title,which was held at the1999Meeting of the American Association for the Advancement of Science.The authors wrote the following:Section1and7–Kolaitis,Section2–Immerman,Section3–Vianu,Section4-Harper,Section5-Halpern,and Section6–Vardi.Cornell University.Work partially supported by NSF Grant IRI-96-25901.Carnegie-Mellon University Work partially supported by NSF Grant CCR-9502674and DARPA Contract F19628-95-C-0050.University of Massachusetts,Amherst.Work partially supported by NSF grant CCR-9877078.University of California,Santa Cruz.Work partially supported by NSF Grant CCR-9610257.Rice University.Work partially supported by NSF Grants CCR-9700061,CCR-9988322,IIS-9978135,and CCR-9988322.University of California,San Diego.Work partially supported by NSF Grant IIS-9802288.Indeed,let us recall that to a large extent mathematical logic was developed in an attempt to confront the crisis in the foundations of mathematics that emerged around the turn of the20th Century.Between1900 and1930,this development was spearheaded by Hilbert’s Program,whose main aim was to formalize all of mathematics and establish that mathematics is complete and rmally,completeness means that all“true”mathematical statements can be“proved”,whereas decidability means that there is a mechanical rule to determine whether a given mathematical statement is“true”or“false”.Hilbertfirmly believed that these ambitious goals could be achieved.Nonetheless,Hilbert’s Program was dealt devastating blows during the1930s.Indeed,the standardfirst-order axioms of arithmetic were shown to be incomplete by G¨o del in his celebrated1931paper[G¨o d31].Furthermore,A.Turing,A.Church,and A.Tarski demonstrated the undecidability offirst-order logic.Specifically,the set of all validfirst-order sentences was shown to be undecidable[Chu36,Tur37],whereas the set of allfirst-order sentences that are true in arithmetic was shown to be highly undecidable[Tar35].Today,mathematical logic is a mature and highly sophisticated research area with deep results and a number of applications in certain areas of mathematics.All in all,however,it is fair to say that the interaction between logic and mathematics has been rather limited.In particular,mathematical logic is not perceived as one of the mainstream area of mathematics,and the“typical”mathematician usually knows little about logic.Along these lines,R.W.Hamming’s judgment[Ham80]is not uncommon,albeit perhaps severe:“...we have had an intense study of what is called the foundations of mathematics...It is an interesting field,but the main results of mathematics are impervious to what is found there.”In contrast,logic has permeated through computer science during the past thirty years much more than it has through mathematics during the past one hundred years.Indeed,at present concepts and methods of logic occupy a central place in computer science,insomuch that logic has been called“the calculus of computer science”[MW85].Our goal in this article is to illustrate the effectiveness of logic in computer science by focusing on just a few of the many areas of computer science on which logic has had a definite and lasting impact.Specifically,the connections between logic and computational complexity will be high-lighted in Section2,the successful use offirst-order logic as a database query language will be illustrated in Section3,the influence of type theory in programming language research will be addressed in Section4,the deployment of epistemic logic to reason about knowledge in multi-agent systems will be covered in Section 5,and the connections between logic and automated design verification will be presented in Section6.2Descriptive ComplexityA fundamental issue in theoretical computer science is the computational complexity of problems.How much time and how much memory space is needed to solve a particular problem?Let DTIME be the set of problems that can be solved by algorithms that perform at moststeps for inputs of size.The complexity class Polynomial Time(P)is the set of problems that are solvable in time at most some polynomial in.Formally,P DTIME.Some important computational problems appear to require more than polynomial time.An interesting class of such problems is contained in nondeterministic polynomial time(NP).A nondeterministic compu-tation is one that may make arbitrary choices as it works.If any of these choices lead to an accept state,then we say the input is accepted.The three-colorability problem—testing whether an undirected graph can have its vertices colored with three colors so that no two adjacent vertices have the same color—as well as hundreds of other well-known combinatorial problems are NP-complete.(See[GJ79]for a survey of many of these.)This means that not only are they in NP,but they are the“hardest problems”in NP:all problems in NP are reducible(in polynomial time)to each NP-complete problem.At present,the fastest known algorithm for any of these problems is exponential.An efficient algorithm for any one of these problems would translate to an efficientalgorithm for all of them.The P NP question,which asks whether P and NP coincide,is an example of our inability to determine what can or cannot be computed in a certain amount of computational resource: time,space,parallel time,etc.Complexity theory typically considers yes/no problems.This is the examination of the difficulty of computing a particular bit of the desired output.Yes/no problems are properties of the input.The set of all inputs to which the answer is“yes”have the property in question.Rather than asking the complexity of checking if a certain input has a property,in Descriptive Complexity we ask how hard is it to express the property in some logic.It is plausible that properties that are harder to check might be harder to express. What is surprising is how closely logic mimics computation:descriptive complexity exactly captures the important complexity classes.In Descriptive Complexity we view inputs asfinite logical structures,e.g.,a graph is a logical structurewhose universe is the set of vertices and is the binary edge relation. Proviso:We will assume unless otherwise stated that a total ordering relation on the universe()is avail-able.Infirst-order logic we can express simple properties of our input structures.For example the following says that there are exactly two edges leaving every vertex.In second-order logic we also have variables that range over relations over the universe.These variables may be quantified.A second-order existential formula(SO)begins with second order existential quantifiers and is followed by afirst-order formula.As an example,the following second-order existential sentence says that the graph in question is three-colorable.It does this by asserting that there are three unary relations,Red(R),Yellow(Y),and Blue(B),defined on the universe of vertices.It goes on to say that every vertex has some color and no two adjacent vertices have the same color.Descriptive Complexity began with the following theorem of R.Fagin.Observe that Fagin’s Theorem characterizes the complexity class NP purely by logic,with no mention of machines or time,Theorem1([Fag74])A set of structures is in NP iff there exists a second-order existential formula, such that.Formally,NP SO.Define CRAM to be the set of properties checkable by concurrent-read,concurrent-write,parallel random-access machines using polynomially many processors in parallel time.FO,the set offirst-order expressible properties,exactly captures the complexity class CRAM[1],i.e.,constant parallel time.It is possible to increase the power of FO by allowing longer descriptions for longer inputs.Let FO be those properties describable by a block of restricted quantifiers that may be iterated times for inputs of size.Theorem2([Imm88])For all constructible1,FO CRAM.1“Constructible”means that the function can be computed in space.All but very bizarre functions are con-structible.Another proviso of this theorem is that for,thefirst-order formulas may have access not only to ordering but to the addition and multiplication relations on the-element universe.Thus,parallel time corresponds exactly tofirst-order iteration,i.e.,quantifier-depth.Rather than iterating blocks of quantifiers,a natural way to increase the power offirst-order logic is by allowing inductive defini-tions.This is formalized via a least-fixed-point operator(LFP).As an example,the reflexive,transitive closure of the edge relation can be defined via the following inductive definition,Equivalently,this can be expressed using the least-fixed-point operator,LFPIt is exciting that the natural descriptive class FO(LFP)—first-order logic extended with the power to define new relations by induction—precisely captures polynomial time.Theorem3([Imm82,Imm86,Var82])A problem is in polynomial time iff it is describable infirst-order logic with the addition of the least-fixed-point operator.This is equivalent to being expressible by afirst-order formula iterated polynomially many times.Formally,P FO LFP FO.Theorems1and3cast the P NP question in a different light.(In the following we are using the fact that if P were equal to NP,then NP would be closed under complementation.It would then follow that every second-order formula would be equivalent to a second-order existential one.)Corollary4P is equal to NP iff every second-order expressible property overfinite,ordered structures is al-ready expressible infirst-order logic using inductive definitions.In symbols,P NP FO LFP SO.The following theorem considers the arbitrary iteration offirst-order formulas,which is the same as iterating them exponentially,and is more general than monotone iteration offirst-order formulas.Such iteration defines the partial-fixed-point operator.The theorem shows that this allows the description of exactly all properties computable using a polynomial amount of space.Theorem5([Imm81,Imm82,Var82])A problem is in polynomial space iff it is describable infirst logic with the addition of the partial-fixed-point operator.This is equivalent to being expressible by afirst-order formula iterated exponentially.Formally,PSPACE FO PFP FO.A refinement of Theorem5shows that the precise amount of space used can be characterized via the number of distinct variables in the relevantfirst-order formula,i.e.,the number of descriptive variables captures space,for,DSPACE V AR,[Imm91].Combinatorial games due to Ehrenfeucht and Fra¨ıss´e have been used to prove many inexpressibility results.These bounds provide useful insights but they do not separate relevant complexity classes because they are proved without the ordering relation[Ehr61,Fra54,Imm99].No such lower bounds were known for separating the classes corresponding to P and PSPACE.Abiteboul and Vianu showed why,thus proving another fundamental relationship between logic and complexity.In the following,FO(wo)meansfirst-order logic without a given ordering relation.Theorem6([A V91])The following conditions are equivalent:1.FO(wo)LFP FO(wo)PFP2.FO LFP FO PFP3.P PSPACEDescriptive complexity reveals a simple but elegant view of computation.Natural complexity classes and measures such as polynomial time,nondeterministic polynomial time,parallel time,and space have natural descriptive characterizations.Thus,logic has been an effective tool for answering some of the basic questions in complexity.23Logic as a Database Query LanguageThe database area is an important area of computer science concerned with storing,querying and updating large amounts of data.Logic and databases have been intimately connected since the birth of database systems in the early1970’s.Their relationship is an unqualified success story.Indeed,first-order logic (FO)lies at the core of modern database systems,and the standard query languages such as Structured Query Language(SQL)and Query-By-Example(QBE)are syntactic variants of FO.More powerful query languages are based on extensions of FO with recursion,and are reminiscent of the well-knownfixpoint queries studied infinite-model theory(see Section2).The impact of logic on databases is one of the most striking examples of the effectiveness of logic in computer science.This section discusses the question of why FO has turned out to be so successful as a query language. We will focus on three main reasons:FO has syntactic variants that are easy to use.These are used as basic building blocks in practical languages like SQL and QBE.FO can be efficiently implemented using relational algebra,which provides a set of simple operations on relations expressing all FO queries.Relational algebra as used in the context of databases was introduced by Ted Codd in[Cod70].It is related to Tarski’s Cylindric Algebras[HMT71].The algebra turns out to yield a crucial advantage when large amounts of data are concerned.Indeed,the realization by Codd that the algebra can be used to efficiently implement FO queries gave the initial impetus to the birth of relational database systems3.FO queries have the potential for“perfect scaling”to large databases.If massive parallelism is avail-able,FO queries can in principle be evaluated in constant time,independent of the database size.A relational database can be viewed as afinite relational structure.Its signature is much like a relational FO signature,with the minor difference that relations and their coordinates have names.The name of a coordinate is called an attribute,and the set of attributes of a relation is denoted.For example,a “beer drinker’s”database might consist of the following relations:frequents drinker barJoe King’sJoe Molly’sSue Molly’s serves bar beerKing’s BassKing’s BudMolly’s BassThe main use of a database is to query its data,e.g.,find the drinkers who frequent only bars serving Bass.It turns out that each query expressible in FO can be broken down into a sequence of simple subqueries.2This section is based in part on the article[Imm95].See also the books[EF95,Imm99]for much more information about descriptive complexity.3Codd received the ACM Turing Award for his work leading to the development of relational systems.Each subquery produces an intermediate result,that may be used by subsequent subqueries.A subquery isof the form:where is a literal or,is in the input or is on the left-hand side of a previous subquery inthe sequence,and is not in the input and does not occur previously in the sequence.The meaning of sucha subquery is to assign to the result of the FO query on the structure resulting from the evaluation of the previous subqueries in the sequence.The subqueries provide appealing building blocks forFO queries.This is illustrated by the language QBE,in which a query is formulated as just described.Forexample,consider the following query on the“beer drinker’s”database:Find the drinkers who frequent some bar serving Bass.This can be expressed by a single query of the above form:answer frequents serves BassIn QBE,the query is formulated in a visually appealing way as follows:answer drinker frequents drinker bar serves bar beerBassSimilar building blocks are used in SQL,the standard query language for relational database systems.Let us consider again the query.The naive implementation would have us check,for each drinker and bar,whether holds.The number of checks is then the product of the number of drinkers and the number of bars in the database,which can be roughly in the size of the database.This turns out to be infeasible for very large databases.A better approach,and the one used in practice,makes use of relational algebra.Before discussing how this works,we informally review the algebra’s operators.There are two set operators,(union)and(difference).The selection operator, denoted extracts from the tuples satisfying a condition cond involving(in)equalities of attribute values and constants.For example,beer Bass serves produces the tuples in serves for which the beer is Bass.The projection operator,denoted,projects the tuples of relation on a subset of its attributes.The join operator,denoted by,consists of all tuples over such that and.A last unary operator allows to rename an attribute of a relation without changing its contents.Expressions constructed using relational algebra operators are called relational algebra queries.Thequery is expressed using relational algebra as follows:A result of crucial importance is that FO and relational algebra express precisely the same queries.The key to the efficient implementation of relational algebra queries is twofold.First,individual algebraoperations can be efficiently implemented using data structures called indexes,providing fast access to data.A simple example of such a structure is a binary search tree,which allows locating the tuples with a givenattribute value in time,where is the number of tuples.Second,algebra queries can be simplifiedusing a set of rewriting rules.The query above can be rewritten to the equivalent but more efficient form:drinker frequents bar beer Bass servesThe use of indexes and rewriting rules allows to evaluate the above query at cost roughly in thesize of the database,which is much better than.Indeed,for large databases this can make the differencebetween infeasibility and feasibility.The FO queries turn out to be extremely well-behaved with respect to scaling.Given sufficient resources,response time can in principle be kept constant as the database becomes larger.The key to this remarkableproperty is parallel processing.Admittedly,a lot of processors are needed to achieve this ideal behaviour:polynomial in the size of the database.This is unlikely to be feasible in practice any time soon.The keypoint,however,is that FO query evaluation admits linear scaling;the speed-up is proportional to the numberof parallel processors used.Once again,relational algebra plays a crucial role in the parallel implementation of FO.Indeed,thealgebra operations are set oriented,and thus highlight the intrinsic parallelism in FO queries.For example,consider the projection.The key observation is that one can project the tuples in independently of each other.Given one processor for each tuple in,the projection can be computed in constant time,independent of the number of tuples.As a second example,consider the join.This can be computedby joining all pairs of tuples from and,independently of each other.Thus,if one processor is availablefor each pair,the join can be computed in constant time,independent on the number of tuples in and.Since each algebra operation can be evaluated in constant parallel time,each algebra query can also beevaluated in constant time.The constant depends only on the query and is independent of the size of thedatabase.Of course,more and more processors are needed as the database grows.In practice,the massive parallelism required to achieve perfect scaling is not available.Nevertheless,there are algorithms that can take optimal advantage of a given set of processors.It is also worth noting thatthe processors implementing the algebra need not be powerful,as they are only required to perform veryspecific,simple operations on tuples.In fact,it is sufficient to have processors that can implement the basicBoolean circuit operations.This fact is formalized by a result due to Immerman[Imm87]stating that FOis included in AC,the class of problems solvable by circuits of constant depth and polynomial size,withunbounded fan-in.In conclusion,logic has proven to be a spectacularly effective tool in the database area.FO provides thebasis for the standard query languages,because of its ease of use and efficient implementation via relationalalgebra.FO can achieve linear scaling,given parallel processing resources.Thus,its full potential as a querylanguage remains yet to be realized.A good introduction to the database area may be found in[SKS97],while[Ull88]provides a morein-depth presentation.Thefirst text on database theory is[Mai83],followed more recently by[AHV95].The latter text also described database query languages beyond FO,includingfixpoint logics.An excellentsurvey of relational database theory is provided in[Kan91].The relationship betweenfinite-model theoryand databases is discussed in[Via].4Type Theory in Programming Language ResearchIn the1980’s and1990’s the study of programming languages was revolutionized by a remarkable confluenceof ideas from mathematical and philosophical logic and theoretical computer science.Type theory emergedas a unifying conceptual framework for the design,analysis,and implementation of programming languages.Type theory helps to clarify subtle concepts such as data abstraction,polymorphism,and inheritance.Itprovides a foundation for developing logics of program behavior that are essential for reasoning aboutprograms.It suggests new techniques for implementing compilers that improve the efficiency and integrityof generated code.Type theory is the study of type systems.Reynolds defines a type system to be a“syntactic disciplinefor enforcing levels of abstraction”[Rey85].A type system is a form of context-sensitive grammar thatimposes restrictions on the formation of programs to ensure that a large class of errors,those that arise frommisinterpretation of values,cannot occur.Examples of such errors are:applying a function on the integersto a boolean argument;treating an integer as a pointer to a data structure or a region of executable code;int booltrue false=if then elsefun(:):is()true false fun(:):isThe operator ranges over the arithmetic operations,,and.The variable ranges over numerals for the natural numbers.The variables and are bound in the expression fun(:):is.Figure1:Abstract Syntax of MinMLint int intinttrue bool false boolint int =bool boolif then elsefun(:):is()Figure2:Type System of MinMLover-writing a program’s memory without regard to its purpose or validity;violating the assumptions of a procedure by calling it with too few arguments or arguments of the wrong type.A type system is typically defined by an inductive definition of a typing judgement of the form. Here is an expression,is its type,and assigns types to the global variables that may occur within. The typing judgement is defined to be the least three-place relation closed under a given collection of typing rules that determine whether or not an expression is well-typed.The abstract syntax of an illustrative fragment of the ML language is given in Figure1.Its type system is given in Figure2.Note that the language constructs are grouped according to their type.Each type comes with expressions to denote its values together with operations for manipulating those values in a computation.The rules governing the function type constructor exhibit an intriguing similarity to the introduction and elimination rules for implication in Gentzen’s system of natural deduction.This similarity is not accidental: according to the propositions-as-types principle[CF58,CHS72,How80]there is an isomorphism between propositions and types with the property that the natural deduction proofs of a proposition correspond to the elements of its associated type.This principle extends to the full range of logical connectives and quantifiers, including those of second-and higher-order logic.An operational semantics defines how to execute programs.It is useful to define the operational se-mantics of a language as a transition relation between states of an abstract machine,with certain states=====true false()()()()fun(:):is ()The notation stands for the result of substitution for free occurrences of and for freeoccurrences of in the expression.Figure3:Operational Semantics of MinMLdesignated asfinal states.For the illustrative language of Figure2the states of the abstract machine are closed expressions;thefinal states are the fully-evaluated expressions.The transition relation is given in Figure3using Plotkin’s technique of structured operational semantics[Plo81].These rules constitute an inductive definition of the call-by-value evaluation strategy,in which function arguments are evaluated prior to application,and for which function expressions are fully evaluated.One role of a type system is to preclude execution errors arising from misinterpretation of values. Theorem1:[Type Soundness]If,then either is fully evaluated or there exists such thatand.A type error is an expression such that is not a value,yet there is no such that.In practice type errors correspond to illegal instructions or memory faults;the type soundness theorem ensures that well-typed programs never incur such errors.The structure of more realistic programming languages can be described using very similar techniques. According to the type-theoretic viewpoint programming language“features”correspond to types.The fol-lowing chart summarizes some of the main correspondences:Concept Type Values Operationsbooleans bool true,false conditionalintegers int integer numerals integer arithmeticfloating point float f.p.numerals f.p.arithmetictuples ordered pairs component projectiondisjoint union tagged values case analysisprocedures procedure definition procedure callrecursive types heap pointers traversalpolymorphism templates,generics instantiationdata abstraction packages,modules opening a packagemutable storage ref storage cells update,retrievetagging any tagged values dynamic dispatch Organizing programming languages by their type structure has a number of benefits.We mention a few salient ones here.First,language concepts are presented modularly,avoiding confusion or conflation。
模糊逻辑
Fuzzy LogicLogic, according to Webster's dictionary, is the science of the normative formal principles of reasoning. In this sense, fuzzy logics concerned with the formal principles of approximate reasoning, with precise reasoning viewed as a limiting case.In more specific terms, what is central about fuzzy logic is that, unlike classical logical systems, it aims at modeling the imprecise modes of reasoning that play an essential role in the remarkable human ability to make rational decisions in an environment of uncertainty and imprecision. This ability depends, in turn, on our ability to infer an approximate answer to a question based on a store of knowledge that is inexact, incomplete, or not totally reliable. For example:(1) Usually it takes about an hour to drive from Berkeley to Stanford about half an hour to drive form Stanford to San Jose. How long would it take to drive from Berkeley to San Jose via Stanford?(2)Most of those who live in Belvedere have high incomes. It is probable that Mary lives in Belvedere. What can be said about Mary's income?(3)Slimness is attractive. Carol is slim. Is Carol attractive?(4)Brian is much taller than most of his close friends. How tall is Brian?There are two main reasons why classical logical systems cannot cope with problems of this type. First, they do not provide a system for representing the meaning of propositions expressed in a natural language when the meaning is imprecise; and second, in those cases in which ten meaning can be represented symbolically in a meaning representation language, for example, a semantic network or a conceptual-dependency graph, there is no mechanism for inference.As will be seen, fuzzy logic addresses these problems in the following ways. First, the meaning of a lexically imprecise proposition is represented as an elastic constraint on a variable; and second, the answer to a query is deduced through a propagation of elastic constraints.During the past several years, fuzzy logic has found numerous applications in fields ranging from finance to earthquake engineering. But what is striking is that its mostimportant and visible application today is in a realm not anticipated when fuzzy logic was conceived, namely, the realm of fuzzy-logic-based process control. The basic idea underlying fuzzy logic control was suggested in notes published in 1968 and 1972 and described in greater detail in 1973. The first implementation was pioneered by Mamdani and Asslian in 1974 in connection with the regulation of a steam engine. In the ensuing years, once the basic idea underlying fuzzy logic control because well understood, many applications followed. In japan, in particular, the use of fuzzy logic in control processes is being pursued in many application areas, among them automatic train operation, vehicle control, robot control, speech recognition, and stabilization control. More about some of these projects will be said in the section dealing with applications.In most of the current applications of fuzzy logic, software is employed as a medium for the implementation ,of fuzzy algorithms and control rules. What is clear, however, is that it would be cheaper and more effective to use fuzzy logic chips and , eventually, fuzzy computers. The first logic chip was developed by Togai and Watanabe at Bell Telephone Laboratories in 1985, and it is likely to become available for commercial us in 1988 or 1989. On the heels of this important development came the announcement of a fuzzy computer designed by Yamakawa at Kumamoto University. These developments on the hardware front may lead to an expanded use of fuzzy logic not only in industrial application but, more generally, in knowledge-based systems in which the deduction of an answer to a query requires the inference machinery of fuzzy logic.One important branch of fuzzy logic may be called dispositional logic. This logic, as its name implies, deals with dispositions, that is propositions that are preponderantly but not necessarily always true. For example, "snow is white" is a disposition, as are the propositions "swedes are blond" and " high quality is expensive." a disposition may be viewed as a usuality-qualified proposition in which the qualifying quantifier "usually" is implicit rather than explicit. In this sense, the disposition " snow is white" may be viewed as the result of suppressing the fuzzy quantifier "usually" in the usuality-qualified proposition.In this proposition, "usually" plays the role of a fuzzy proportion of the form shown in Figure 1.The importance of dispositional logic stems from he fact that most of what is usually referred to as common sense knowledge may be viewed as a collection of dispositions. Thus, the main concern of dispositional logic lies in the development of rules inference from common sense knowledge.In what follows, i present a condensed exposition of some basic ideas underlying fuzzy logic and describe some representative applications. More detailed information regarding fuzzy logic and its applications may be found in te cited literature.Fuzzy logic is a problem-solving control system methodology that lends itself to implementation in systems ranging from simple, small, embedded micro-controllers to large, networked, multi-channel PC or workstation-based data acquisition and control systems. It can be implemented in hardware, software, or a combination of both. Fuzzy logic provides a simple way to arrive at a definite conclusion based upon vague, ambiguous, imprecise, noisy, or missing input information. Fuzzy logic's approach to control problems mimics how a person would make decisions, only much faster.Fuzzy logic requires some numerical parameters in order to operate such as what is considered significant error and significant rate-of-change-of-error, but exact values of these numbers are usually not critical unless very responsive performance is required in which case empirical tuning world determine them. For example, a simple temperature control system could use a single temperature feedback sensor whose data is substracted from the command signal to compute "error" and then time-differentiated to yield the error slope or rate-of-change-error, hereafter called "error-dot". Error might have units of degs F and a small error considered to be 2F while a large error is 5F模糊逻辑根据韦氏词典,逻辑是指对规范形式原理推理的科学。
Propositionalvs.PredicateLogic
1First-Order Logic(First-Order Predicate Calculus)2Propositional vs. Predicate Logic •In propositional logic, each possible atomic fact requires aseparate unique propositional symbol.•If there are n people and m locations, representing the factthat some person moved from one location to another requires nm 2 separate symbols.•Predicate logic includes a richer ontology:-objects (terms)-properties (unary predicates on terms)-relations (n -ary predicates on terms)-functions (mappings from terms to other terms)•Allows more flexible and compact representation ofknowledgeMove(x, y, z) for person x moved from location y to z.Syntax for First-Order LogicSentence →AtomicSentence| Sentence Connective Sentence | Quantifier Variable Sentence |¬Sentence | (Sentence)AtomicSentence →Predicate(Term, Term, ...) | Term=Term Term →Function (Term,Term,...)| Constant |Variable Connective → ∨ | ∧ | ⇒ | ⇔Quanitfier → ∃ | ∀Constant → A | John | Car1Variable → x | y | z |...Predicate → Brother | Owns | ...Function → father-of | plus | ...First-Order Logic:Terms and Predicates•Objects are represented by terms :-Constants : Block1, John-Function symbols: father-of, successor, plusAn n -ary function maps a tuple of n terms to another term: father-of(John), succesor(0), plus(plus(1,1),2)•Terms are simply names for objects. Logical functions arenot procedural as in programming languages. They do not need to be defined,and do not really return a value.Allows for the representation of an infinite number of terms.•Propositions are represented by a predicate applied to atuple of terms. A predicate represents a property of or relation between terms that can be true or false:Brother(John, Fred), Left-of(Square1, Square2)GreaterThan(plus(1,1), plus(0,1))•In a given interpretation, an n -ary predicate can defined asa function from tuples of n terms to {T rue, False} or equivalently, a set tuples that satisfy the predicate:{<John, Fred>, <John, T om>, <Bill, Roger>, ...}5Sentences in First-Order Logic •An atomic sentence is simply a predicate applied to a set ofterms.Owns(John,Car1)Sold(John,Car1,Fred)Semantics is True or False depending on the interpretation,i.e. is the predicate true of these arguments.•The standard propositional connectives (∨ ¬ ∧ ⇒ ⇔)can be used to construct complex sentences:Owns(John,Car1)∨ Owns(Fred, Car1)Sold(John,Car1,Fred)⇒¬Owns(John, Car1)Semantics same as in propositional logic.6Quantifiers•Allows statements about entire collections of objects ratherthan having to enumerate the objects by name.•Universal quantifier:∀xAsserts that a sentence is true for all values of variable x ∀x Loves(x, FOPC)∀x Whale(x)⇒ Mammal(x)∀x Grackles(x)⇒ Black(x)∀x (∀y Dog(y) ⇒ Loves(x,y))⇒(∀z Cat(z)⇒ Hates(x,z))•Existential quantifier:∃Asserts that a sentence is true for at least one value of a variable x∃x Loves(x, FOPC)∃x(Cat(x)∧ Color(x,Black)∧ Owns(Mary,x))∃x(∀y Dog(y)⇒ Loves(x,y))∧ (∀z Cat(z)⇒ Hates(x,z))Use of Quantifiers•Universal quantification naturally uses implication:∀x Whale(x)∧Mammal(x)Says that everything in the universe is both a whale and a mammal.•Existential quantification naturally uses conjunction:∃x Owns(Mary,x)⇒ Cat(x)Says either there is something in the universe that Mary does not own or there exists a cat in the universe.∀x Owns(Mary,x)⇒ Cat(x)Says all Mary owns is cats (i.e. everthing Mary owns is a cat). Also true if Mary owns nothing.∀x Cat(x)⇒ Owns(Mary,x)Says that Mary owns all the cats in the universe.Also true if there are no cats in the universe.Nesting Quantifiers•The order of quantifiers of the same type doesn’t matter∀x ∀y(Parent(x,y)∧ Male(y)⇒ Son(y,x))∃x ∃y(Loves(x,y)∧Loves(y,x))•The order of mixed quantifiers does matter:∀x ∃y(Loves(x,y))Says everybody loves somebody, i.e. everyone has someone whom they love.∃y ∀x(Loves(x,y))Says there is someone who is loved by everyone in the universe.∀y ∃x(Loves(x,y))Says everyone has someone who loves them.∃x ∀y(Loves(x,y))Says there is someone who loves everyone in the universe.9Variable Scope•The scope of a variable is the sentence to which thequantifier syntactically applies.•As in a block structured programming language, a variablein a logical expression refers to the closest quantifier within whose scope it appears.∃x (Cat(x)∧∀x(Black (x)))The x in Black(x) is universally quantified Says cats exist and everything is black•In a well-formed formula (wff ) all variables should beproperly introduced:∃xP(y)not well-formed•A ground expression contains no variables.10Relation Between Quantifiers•Universal and existential quantification are logically relatedto each other:∀x ¬Love(x,Saddam)⇔ ¬∃x Loves(x,Saddam)∀x Love(x,Princess-Di)⇔ ¬∃x ¬Loves(x,Princess-Di)•General Identities - ∀x ¬P ⇔¬∃x P - ¬∀x P ⇔∃x ¬P - ∀x P ⇔¬∃x ¬P - ∃x P⇔¬∀x ¬P-∀x P(x)∧Q(x)⇔∀xP(x)∧∀xQ(x)-∃x P(x)∨Q(x)⇔∃xP(x) ∨∃xQ(x)Equality •Can include equality as a primitive predicate in the logic,orrequire it to be introduced and axiomitized as the identity relation .•Useful in representing certain types of knowledge:∃x ∃y(Owns(Mary, x)∧ Cat(x) ∧Owns(Mary,y)∧ Cat(y)∧ ¬(x=y))Mary owns two cats. Inequality needed to insure x and y are distinct.∀x ∃y married(x, y)∧∀z(married(x,z)⇒ y=z)Everyone is married to exactly one person. Secondconjunct is needed to guarantee there is only one unique spouse.Higher-Order Logic•FOPC is called first-order because it allows quantifiers torange over objects (terms) but not properties, relations, or functions applied to those objects.•Second-order logic allows quantifiers to range overpredicates and functions as well:∀x ∀y [ (x=y)⇔ (∀p p(x)⇔ p(y)) ]Says that two objects are equal if and only if they have exactly the same properties.∀f ∀g [ (f=g)⇔ (∀x f(x)= g(x)) ]Says that two functions are equal if and only if they have the same value for all possible arguments.•Third-order would allow quantifying over predicates ofpredicates, etc.For example, a second-order predicate would be Symetric(p) stating that a binary predicate p represents a symmetric relation.13Notational Variants •In Prolog, variables in sentences are assumed to beuniversally quantified and implications are represented in a particular syntax.son(X, Y) :- parent(Y ,X), male(X).•In Lisp, a slightly different syntax is common.(forall ?x (forall ?y (implies (and (parent ?y ?x) (male ?x)) (son ?x ?y)))•Generally argument order follows the convention that P(x,y)in English would read “x is (the) P of y”14Logical KB•KB contains general axioms describing the relationsbetween predicates and definitions of predicates using ⇔.∀x,y Bachelor(x)⇔ Male(x)∧ Adult(x)∧¬∃yMarried(x,y).∀x Adult(x)⇔Person(x)∧ Age(x) >=18.•May also contain specific ground facts.Male(Bob), Age(Bob)=21, Married(Bob, Mary)•Can provide queries or goals as questions to the KB:Adult(Bob) ?Bachelor(Bob) ?•If query is existentially quantified, would like to returnsubstitutions or binding lists specifying values for the existential variables that satisfy the query.∃x Adult(x) ?∃x Married(Bob,x) ?{x/Bob} {x/Mary}∃x,y Married(x,y) ?{x/Bob, y/Mary}Sample Representations•There is a barber in town who shaves all men in town whodo not shave themselves.∃x (Barber(x)∧ InT own(x)∧∀y (Man(y)∧ InTown(y)∧ ¬Shave(y,y)⇒ Shave(x,y)))•There is a barber in town who shaves only and all men intown who do not shave themselves.∃x (Barber(x)∧ InT own(x)∧∀y (Man(y)∧ InTown(y)∧ ¬Shave(y,y) ⇔Shave(x,y)))•Classic example of Bertrand Russell used to illustrate aparadox in set theory:Does the set of all sets contain itself?。
Specification, validation, and verification of time-critical systems
Abstract In this paper, we propose a new formalism, named the Timed Communicating Finite State Machine (Timed CFSM), for specifying and verifying time-critical systems. Timed CFSM preserves the advantages of CFSM, such as the ability to express communication, synchronization and concurrency in computer systems. A given time-dependent specification can be formalized as a Timed CFSM, from which the reachability graph is constructed to verify the correctness of the specification. To cope with the space explosion problem from which all reachability analysis methods suffer, we propose a space reduction algorithm to meet the space constraint of the verification environment. 0 1998 Elsevier Science B.V.
Departmenr of Cornpurer Science and Information Engineering, National Chiao Tung University, Hsinchu 30010, Taiwan
为什么培养逻辑推理能力很重要英语作文
为什么培养逻辑推理能力很重要英语作文全文共3篇示例,供读者参考篇1Why Learning to Think Logically is Super ImportantDo you ever feel like your brain is a jumbled mess? One minute you're thinking about your math homework, the next you're daydreaming about your favorite video game, and then you remember you haven't fed your pet hamster yet! Having good logical thinking skills helps put some order to all those whirling thoughts. But why is being a logical thinker so vital? Let me explain!Figuring Out the Right Thing to DoWe face loads of choices and decisions every single day, some small like what to have for lunch, others way bigger like which after-school club to join. Logical reasoning helps us think through all the篇2Why It's Super Important to Get Good at Logical ThinkingHi there! My name is Jamie and I'm a 10-year-old kid who really likes using my brain to solve tricky problems and puzzles. I've learned that having strong logical reasoning skills is a total superpower that helps me out in so many ways. Let me explain why developing this ability is seriously important!First off, what even is logical reasoning? It's all about using facts and evidence to draw conclusions through rational,step-by-step thinking. Instead of just guessing or going with your gut feeling, you analyze information carefully to figure out what makes the most sense. You connect the dots between different ideas to arrive at a logical solution.Sounds kind of boring and school-ish, right? But trust me, logical reasoning is honestly the coolest! It's like being a mini detective or scientist, gathering clues and data to crack the case. Except the cases you're cracking are the riddles and mysteries of life itself. How awesome is that?Okay, now let me give you some examples of why this skill is so handy and important:It helps you spot faulty thinking and bad arguments.When someone tries to convince you of something fishy, you can use logic to poke holes in their reasoning. Like if yourfriend says "Chocolate is healthy because it has milk in it, and milk builds strong bones!" you can counter with "But chocolate also has way too much sugar, which is unhealthy." Bam! Flawed argument deflated with the power of logic.You can make way smarter decisions.Instead of just going along with peer pressure or impulses, you can calmly weigh the evidence for different choices. Like if you're deciding between buying a new video game or saving that money, logic helps you think through the pros and cons to pick the wisest option.You become a problem-solving master.Having a logical mindset means you don't just give up when faced with a tough problem. You break it down into parts and systematically work through possible solutions until you find one that makes sense. This serves you well on tests, projects, or any challenge life throws your way.It prepares you for advanced skills.Subjects like coding, math, and science rely hugely on logic and analytical reasoning. Getting good at it now sets you up to really excel at those more difficultsubjects in the future. Heck,even if you want to be an artist or writer, bringing more logic into your creative process can only improve your work.You can grasp complex ideas better.As you move through school and life, you'll be exposed to more and more complicated concepts and theories. Having a solid logical foundation helps you understand how all the pieces fit together cohesively instead of just memorizing disconnected facts.It helps you win arguments and debates.I know, I know - arguing isn't everything. But sometimes you need to advocate for your viewpoint, like when you're trying to convince your parents of something. If you can lay out a logical, evidence-based case, you're much more likely to be persuasive.Those are just a few of the reasons why taking time now to actively build your logical reasoning abilities is so valuable. It may feel like a lot of work sometimes, constantly asking yourself "Does this make sense?" and "How can I back that up?" But it's mental exercise that makes your brain muscles super strong and fexy (that's "flexible" plus "sexy" - I'm working on making it a thing).Here are some of my favorite ways to practice logical thinking skills:• Brainteasers and logic puzzles - They're kind of likepush-ups for your gray matter. The more you train with them, the more your logical muscles bulk up. Seriously, everyone should do a few logic puzzles every day. They're crazy fun once you get the hang of them!• Questioning assumptions - Whenever you hear a claim or statement, force yourself to ask "Why is that true? What's the evidence?" Don't just accept things at face value. Dig deeper to analyze the reasoning behind it.• Explaining your thinking - After you solve a problem or make a decision, practice clearly laying out the chain of logic you used to get there. Explain your thinking step-by-step, justifying each mental move. It'll reinforce your logical pathways.• Breaking things down - When faced with a complex concept, task, or situation, break it down into basic parts and logically visualize how each piece connects and impacts the whole system. This analytical approach makes anything less overwhelming.• Looking for counterarguments - Whenever you come up with a viewpoint or proposed solution, challenge yourself to poke holes in it and find potential flaws in your logic. Considering multiple angles and perspectives leads to more sound conclusions.• Asking "What if?" - Change the variables and imagine how your logic would need to adapt. "What if this fact was different? What if we removed this constraint?" Exploring hypotheticals stretches your logical flexibility.The best part is, training your logical reasoning muscles doesn't require any fancy equipment or sources. Every moment of every day contains opportunities to observe, analyze, question, connect ideas, and put your brain through a vigorous workout!You're probably thinking: "Okay, I get it - logic is radical for solving problems and stuff. But why is it so incredibly IMPORTANT to get good at this stuff now?"Here's the deal, my friends. We live in an age ofmind-boggling complexity and information overload. The world is only getting more fast-paced, ambiguous, and bombarded with misinformation, delusion, and hollow rationalizations.If you don't cultivate strong critical thinking and logic skills now, you'll be wandering through life vulnerable to every trick, scam, conspiracy theory, and foolish decision that comes your way. You'll struggle to navigate professional challenges, manage risks and uncertainties, and cut through deception and nonsense.But if you DO develop a powerful logical mind and habit of reasoned analysis at a young age, you'll have a SECRET WEAPON to slay this confusing modern world. No matter how tangled or complicated a situation becomes, your capacity for structured, rational thinking will be a trusty sword that cleaves through the knot of ambiguity. Smooth-talking charlatans and emotive demagogues won't be able to pull the wool over your eyes so easily.You'll have the intellectual self-reliance to size up claims for yourself and separate fact from fallacy. Your decisions - from the small choices about how to spend money to the huge choices about what career to pursue or person to marry - will be guided by rationality and wisdom instead of just going with your gut or following the crowd.In our oversaturated media landscape of polarized misinformation, you'll be able to plainly see through agendasand manipulations cloaked in cloudy rhetoric and emotional language. You'll be one of the rare, precious few who actually analyzes the cold hard logic and arrives at your OWN understanding, rather than mindlessly soaking up whatever narrative is most heavily marketed to you.And when misinformed people hurl lazy, sloppy arguments your way (which will happen constantly in this era), you'll be able to slap 'em down and obliterate 'em with tightly structured, iron-clad logic and reasoning of your own. You'll have the superpower to elegantly deconstruct falsehoods, plot-holes, and nonsensical gibberish that so many people fall for nowadays.Basically, to thrive and stay sane in the insanity of the modern world, a laser-focused mind and flawless logical reasoning abilities aren't just some optional cerebral luxuries. They're essential functional necessities for anyone hoping to navigate the Bullshit Blizzard, as I call it. Those who can cut through the noise and bunkum using disciplined logic will be the ones who make it through to the other side.So yeah...I'd say developing your powers of logic, critical analysis, and reasoned skepticism now is one of the most CRITICALLY IMPORTANT skills you can cultivate, my friends. It'll help you achieve your potential in school and career. It'll giveyou a framework for leading an ethical, purposeful life aligned with truth and wisdom. And it'll be your secret weapon for battling widespread folly, manipulations, and deceptive agendas in this crazy world.Okay, I could go on and on, but you get the point. Just please, please make developing elite-level logic and reasoning skills one of your top priorities as a young learner and future guardian of clarity. The world desperately needs more sharp logical thinkers to counter the onslaught of muddled thinking and nonsense out there.Nurture and protect your brilliant young minds! Become junkbusters of bad logic and fallacious reasoning! Join me on this noble quest to make rational sense of an often irrational world!Who's with me? Let's get logicizinating!篇3Why Learning Logical Reasoning is Super ImportantHi there! My name is Alex, and I'm 10 years old. Today, I want to tell you all about why developing our ability to reason logically is such an awesome and crucial thing. It's kind of like a superpower that can help us in so many ways!First off, let me explain what logical reasoning actually means. It's all about using facts and evidence to draw conclusions and solve problems step-by-step. Instead of just guessing or believing whatever someone tells us, we look at the information we have and connect the dots in a clear, rational way.For example, let's say I want a chocolate chip cookie, but my mom said I can't have one until I finish my vegetables. If I use logical reasoning, I'll realize that in order to get that yummy cookie, I need to eat all my veggies first. It's like putting the puzzle pieces together - veggie-eating leads to cookie-getting. Simple as that!Logical reasoning also helps us spot contradictions when things don't quite add up. Like if my friend tells me they're great at basketball but can't even dribble a ball, I'd be like "Hmm, something doesn't seem right here!" Using logic, I can figure out if what I'm being told actually makes sense or not.So why is developing this skill so freakin' important? Well, there are loads of reasons!Firstly, it'll make us way better at solving all kinds of problems, whether it's a tricky math question or figuring out the mystery of who ate the last slice of pizza. By thinking logicallyand going step-by-step, we can break things down into smaller pieces until we get to the solution. No more getting stumped and feeling stuck!It'll also help us out a ton in our schoolwork and studies. So many subjects, like science, require us to make observations, analyze data, and draw reasonable conclusions based on evidence. If we can think logically, we'll totally excel at understanding complex topics and acing those tests. Watch out, Einstein!But logical reasoning doesn't just come in handy at school. It'll make us awesome decision-makers in every area of our lives. Whether we're choosing what game to play, what book to read next, or even what career to pursue when we're older, using logic will ensure we make wise choices that we won't regret later.Another huge benefit is that it'll help us spot misleading information and resist falling for cons, tricks, or faulty arguments. Scammers and tricksters might try to fool us with claims that just don't hold up under scrutiny. But if we've got sharp logical reasoning abilities, we'll be able to see right through their bogus nonsense and avoid getting ripped off or misled.Developing our logical skills can even help us be more open-minded and tolerant of different perspectives. Instead ofjust dismissing opinions or beliefs that differ from our own, we can use reasoning to truly understand where others are coming from and have productive discussions. We'll be able to see the logic (or lack thereof) in various viewpoints.Basically, honing this awesome intellectual superpower gives us a strong set of tools for thinking critically about the world around us. It'll make us curious questioners who don't just accept things at face value but dig deeper to understand the reasoning behind claims and ideas. We'll be able to separate fact from fiction, truth from trickery.Now, you might be wondering "How the heck do I get better at logical reasoning anyway?" There are lots of fun ways!For starters, any kind of puzzle, brain teaser, or riddle is an excellent logical reasoning workout. Whether it's a classic like a Rubik's cube or some mind-bending logic problems, tackling these gets our analytical thinking skills fired up. I love challenging myself with new stumpers every day.We can also practice by analyzing stories, situations, or dialogues and looking for flaws in the reasoning. Like, if a book character does something that doesn't really make sense given what we know about them, we can discuss why their actionsseem illogical. Getting into the habit of always questioning and evaluating will sharpen our skills big time.Games and academic subjects that require strategic thinking or deduction are also amazing logical reasoning builders. Things like chess, coding, math problems, and science experiments get us actively using evidence to make informed decisions and conclusions.The best part is, developing stronger logical faculties at a young age will benefit us for our whole lives. It'll help us be more successful students, professionals, and just all-around awesome human beings who can think through problems and ideas clearly and rationally.So there you have it! I hope I've convinced you how unbelievably vital and useful the ability to reason logically is. It's honestly one of the most powerful tools we can equip ourselves with. Just imagine - by harnessing the forces of logic and critical thinking, we can solve any mystery, conquer any challenge, and sharpen our minds beyond belief. We'll be invincible!Now if you'll excuse me, I have a plate of veggies to conquer so I can engage in some high-level logical reasoning...over a chocolate chip cookie. Happy logicking, friends!。
流程式逻辑顺序最经典的三个例子
流程式逻辑顺序最经典的三个例子Flowchart logic is an essential part of programming and problem-solving in various fields. It helps to visualize the sequence of steps in a process, making it easier to understand and analyze. There are numerous classic examples of flowchart logic that have stood the test of time and are widely used across different industries.流程图逻辑是各个领域中编程和问题解决的重要组成部分。
它有助于可视化过程中步骤的顺序,使得更容易理解和分析。
有许多经典的流程图逻辑示例经受住了时间的考验,在不同行业广泛应用。
One of the most classic examples of flowchart logic is the "if-else" statement. This statement is used to make decisions based on certain conditions. It consists of an "if" block, a condition, and an "else" block. When the condition is true, the "if" block is executed, and when the condition is false, the "else" block is executed. This logic is extremely useful in programming to control the flow of execution based on different scenarios.最经典的流程图逻辑之一是“if-else”语句。
给出你对一阶谓词逻辑知识表示方法的理解。
给出你对一阶谓词逻辑知识表示方法的理解。
一阶谓词逻辑(First-Order Predicate Logic)是一种形式化的表示方法,用于描述现实世界中的事物、关系和属性。
它是数理逻辑的一种分支,也是人工智能领域中知识表示和推理的重要工具。
一阶谓词逻辑的基本元素包括常量、变量、谓词和量词。
常量表示具体的个体,如"John"、"Mary";变量表示未知的个体,如"x"、"y";谓词表示个体之间的关系或属性,如"父亲"、"大于";量词用于限定变量的范围,如"存在"、"对于所有"。
通过将这些元素进行组合和约束,可以构建复杂的逻辑表达式来描述问题的语义。
一阶谓词逻辑使用符号来表示逻辑表达式,如∀表示"对于所有",∃表示"存在",∧表示"逻辑与",∨表示"逻辑或",¬表示"逻辑非",→表示"蕴含"等。
这些符号的组合形成了一阶谓词逻辑的语法规则,用于构建合法的逻辑表达式。
一阶谓词逻辑的应用非常广泛。
它可以用来描述事实、规则和约束,用于知识表示和推理。
在人工智能领域中,一阶谓词逻辑常用于构建知识库和专家系统,用于表达和推理关于世界的知识。
例如,可以使用一阶谓词逻辑来描述"父亲"和"母亲"的关系,以及根据这一关系推理出"祖父"和"祖母"的关系。
一阶谓词逻辑还可以用于形式化推理和证明。
通过使用逻辑推理规则和推理机制,可以根据已知的事实和规则推导出新的结论。
这种推理过程可以用于解决各种问题,如谓词逻辑的合一和归结问题。
一阶谓词逻辑还具有表达能力强、灵活性高的特点。
五,VHDL语言的顺序语句
x <= a ;
-- 无复位信号,执行赋值操作
WAIT UNTIL clock ='1' AND clock’EVENT; -- 等待时钟信号
NEXT rst_loop When (rst='1'); -- 检测复位信号rst
y <= b ;
-- 无复位信号,执行赋值操作
END LOOP rst_loop ;
和基本逻辑功能,其中包括通信的方式、信号的赋值、 多层次的元件例化以及系统行为等。
[理解]
顺序语句是相对于并行语句而言的,其特点 是每一条顺序语句的执行(指仿真执行)顺序是与 它们的书写顺序基本一致的,
顺序语句只能出现在 进程(PROCESS) 过程(PROCEDURE) 函数(FUNCTION)
目的信号 <= 表达式;
例:y<=‘1’;
信号赋值可以在顺序区域内作顺序语句,也可以 在结构体中当作并行语句使用。
2、流程控制语句
A、IF 语句
第一种
IF 条件句 THEN 顺序语句; END IF;
第二种
IF 条件句 THEN 顺序语句; ELSE 顺序语句; END IF;
第三种
IF 条件句1 THEN 顺序语句1; ELSIF 条件2 THEN 顺序语句2; … ELSIF 条件n THEN 顺序语句n; ELSE 顺序语句n+1; END IF;
WAIT语句 过程调用 函数调用
RETURN语句
IF语句 CASE语句 LOOP语句 NEXT语句 EXIT语句
6、空操作语句
NULL语句
1、赋值语句
A、变量赋值语句
例:x:=15;
目的变量 := 表达式;
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Abstract. We provide a denotational semantics for first-order logic that captures the two-level view of the computation process typical for constraint programming. At one level we have the usual program execution. At the other level an automatic maintenance of the constraint store takes place. We prove that the resulting semantics is sound with respect to the truth definition. By instantiating it by specific forms of constraint management policies we obtain several sound evaluation policies of first-order formulas. This semantics can also be used a basis for sound implementation of constraint maintenance in presence of block declarations and conditionals.
is satisfied by the substitution {x/0}. The question is whether we can capture this concept of “straightforwardness” in a natural way. Our first attempt to answer this question was given in Apt and Bezem [3] by providing a natural operational semantics for first-order logic which is independent of the underlying interpretation for it. It captures the computation process as a search for a satisfying substitution for the formula in question. Because the problem of finding such a substitution is in general undecidable, we introduced in it the possibility of a partial answers in the form of a special error state indicating a run-time error. In Apt [2] we slightly extend this approach by
First-order Logic as a Constraint Programming Language
K. R. Apt1,2 and C. F. M. Vermeulen1
arXiv:cs/0208032v2 [cs.LO] 19 Nov 2002
1
CWI, P.O. Box 94079, 1090 GB Amsterdam, the Netherlandsห้องสมุดไป่ตู้2 University of Amsterdam, the Netherlands
explaining how more general equalities can be handled and formulate it in the form of a denotational semantics for first-order logic. Unfortunately, both semantics are too weak to deal properly with formulas (1) and (2): for both of them the error state is generated. In this paper we try to overcome these limitations by providing a computational interpretation of first-order logic in the spirit of constraint programming. According to this view the computation process takes place on two levels. At one level we have the usual program execution. At the other level, in the “background” inaccessible to the user, an automatic maintenance of the constraint store takes place. The problem we tackle is undecidable, so we introduce the possibility of partial answers. They are modeled now by a non-empty constraint store or the error state. The automatic maintenance of the constraint store is modeled by a parametric infer operation that acts on states. The idea of an abstract infer operation is due to Jaffar and Maher [9]. Here we consider it in presence of arbitrary first-order formulas. Because of this generality we can obtain various sound realizations of the constraint store management by appropriately instantiating infer. The correctness of this approach is formalized in the form of an appropriate soundness result. To establish it we need to assume some properties of the infer operation. They are formulated as five “healthiness” conditions. To illustrate the benefits of this view of first-order logic and to show the scope of the soundness result, we discuss several ways of instantiating the infer parameter to specific constraint management policies. Examples include admission of a constraint store consisting of arbitrary first-order formulas, restriction to a constraint store consisting only of atomic constraints, and restriction to a constraint store consisting only of arbitrary first-order positive formulas. We can also discuss in this framework in a uniform way unification, an algorithm for solving equations and disequations over the Herbrand algebra, and Gaussian elimination in presence of arithmetic constraints. On the more practical side, these considerations lead to specific implementation proposals of the constraint store in presence of block declarations and conditionals, here modeled, respectively, by means of existential quantification and of negation, conjunction and disjunction. To clarify these issues we return to formula (1). If we do not admit a constraint store, as in the semantics of [3] and [2], its evaluation yields the error state, since we cannot evaluate y < z without knowing the values for y and z . But if we do allow atomic constraints in the store, we can postpone the evaluation of y < z and the evaluation yields the substitution {y/1, z/2}. Next, let us reconsider formula (2). If only atomic formulas are allowed as constraints, the evaluation of this formula yields the error state, since we can neither evaluate ¬(x = 1) nor add this formula to the constraint store. If, however, negated formulas are allowed in the constraint store the substitution {x/0} is an answer. The soundness theorem states that each computed substitution satisfies the evaluated formula. 2