
Conceptive C
Harry McGeough
Version 1.0 Published by Harry McGeough at Smashwords
ISBN-13: 978-1465934888
ISBN-10: 1465934888
Copyright 2011 Harry McGeough
About Cover Image
A billowing tower of gas and dust rises from the stellar nursery known as the Eagle Nebula. This small piece of the Eagle Nebula is 57 trillion miles long (91.7 trillion km).
Credit: NASA, ESA, and The Hubble Heritage Team (STScI/AURA)
![]()
Conceptive C by Harry McGeough is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at www.wikipedia.com.
Permissions beyond the scope of this license may be available at http://www.wikipedia.com.
Contents
Preface
Natural Language
Basic English
Word Definition
Machine Learning
Compiler Changes
Know Thyself
AI
History
Deduction, Reasoning, Problem Solving
Knowledge Representation
Commonsense Knowledge
Learning
Natural Language Processing
Creativity
General Intelligence
Evaluating progress
Philosophy
C Language
Characteristics
Early Developments
K&R C
ANSI C and ISO C
C99
Embedded C
Uses
Syntax
Keywords
Operators
"Hello, world" Example
Data Types
Pointers
Arrays
Array-pointer Interchangeability
Memory Management
Libraries
Objective C
History
Popularization through NeXT
Syntax
Messages
Interfaces and Implementations
Implementation
Instantiation
Protocols
Dynamic Typing
Forwarding
Categories
#import
Objective-C 2.0
Garbage Collection
Properties
Non-fragile Instance Variables
Fast Enumeration
Library Use
Analysis of the Language
Lisp
Connection to Artificial Intelligence
Symbolic expressions
Lists
Operators
Lambda Expressions
Atoms
Conses and Lists
S-expressions Represent Lists
List-Processing Procedures
Shared Structure
Self-evaluating Forms and Quoting
List Structure of Program Code
Evaluation and the Read–Eval–Print Loop
Object Systems
Conceptive C
Syntax
Messages
Interfaces and Implementations
Interface
Instantiation
Dynamic Typing
Changes from Objective-C
Machine Intelligence
New Ideas
Idea
Innate and Adventitious Ideas
Plato
René Descartes
John Locke
David Hume
Immanuel Kant
Rudolf Steiner
Wilhelm Wundt
Charles Sanders Peirce
G.F. Stout and J.M. Baldwin
Anthropology and the Social Sciences
Dr. Samuel Johnson
Validity of Ideas
Concept
What is a Concept?
Origin and Acquisition of Concepts
Pure Concepts
Conceptual Structure
One Possible Structure
The Dual Nature of Concepts
Conceptual Content
Concepts and Metaphilosophy
Concepts in Epistemology
Ontology of Concepts
Conceptual Empirical Investigations
Memory
Processes
Sensory Memory
Short-Term Memory
Long-Term Memory
Working Memory
Levels of Processing
Information Type
Temporal Direction
Physiology
Mind
Concept of Mind
Etymology
Mental Faculties
Mental Content
Cognitive Science
Philosophy of Mind
Mind / Body Perspectives
Psychology
Evolutionary Psychology
Evolution of the Human Mind
Animal intelligence
Artificial intelligence
Meme
Origins
Transmission
Memes as Discrete Units
Evolutions Influences on Memes
Cell
Anatomy
Prokaryotic Cells
Eukaryotic Cells
Genetic Material
Origin of the First Cell
Computer Cell
Soul
Etymology
Semantics
Philosophical views
Aristotle
Avicenna and Ibn Al-Nafis
Thomas Aquinas
Immanuel Kant
James Hillman
Philosophy of Mind
Buddhism
Judaism
Christianity
Roman Catholic Beliefs
Hinduism
Islam
Taoism
Zoroastrianism
Spirituality and New Age
Science
Understanding
Is Understanding Definable?
Understanding Basic English
Rules of word use
Operations - 100 words
400 General Words
Things - 200 Picture-able Words
Qualities - 100 Descriptive words
Qualities - 50 opposites
Consciousness
Etymology and Early History
In Philosophy
Is Consciousness a Valid Concept?
Is It a Single Thing?
How does it relate to the Physical World?
Why do people believe that other people are Conscious?
Are non-human animals are Conscious?
Could a Machine ever be Conscious?
Spiritual Approaches
Scientific Approaches
Biological Function and Evolution
States of Consciousness
Phenomenology
Assessment
The Stream of Consciousness
Thought Experiment
The Chinese Room
Chinese Room Thought Experiment
History
Computationalism
Strong AI
Strong AI as Functionalism
Computers vs. Machines vs. Brains
Intentionality vs. Consciousness
Strong AI vs. AI research
System Reply
Virtual Mind Reply
Finding the Meaning
Robot Reply
Derived Meaning
Commonsense Knowledge
Brain Simulator Reply
Formal Arguments
Mind Uploading
Simple Artificial Neural Network
Immortality/Backup
Speedup
Multiple / Parallel Existence
Computational Capacity
Simulation Model Scale
Scanning and Mapping Scale of an Individual
Serial Sectioning of a Brain
Brain Imaging
Neuroinformatics
Legal, Political and Economical Issues
Copying vs. Moving
Bekenstein Bound
Bots
Chatter Bot
ELIZA
IRC Bot
Avatar
Norman Spinrad
William Gibson
Neal Stephenson
Artificial Intelligence
Video Games
AIML
Categories
Patterns
Template
AIML 1.0 Tag Set
While writing this book I started quoting from Wikipedia. Then including sections, then whole parts of Wiki... I would highly recommend using http://www.wikipedia.com In fact there is quite a bit from Wiki in the book now. I do plan to edit some of it out.
This did start out as a simple question and answer Bot and grew. I now have an Apple 4S with Siri. So I have been exploring Wolfram Alpha’s website.
I’m still trying to understand how I think to develop the language. It’s a hunch, I have that it should be possible to write a program that understands things, if the right tools are available. I am hoping some of the stuff from Wiki will lead to improvements in Conceptive C Language.
I’m still not sure just yet whether Conceptual-C is in fact a conceptual Language. It is possible that in designing it, I may find that Objective-C already does what I’m trying to do. I’m still not at the stage of knowing what needs to go into the compiler yet.
What a month this has been first Steve Jobs (February 24, 1955 – October 5, 2011) of Apple died. My first computer was an Apple II, then I had a PC, then a Macintosh, a NEXT Station and my current computer, which I’m very happy with is an iMac. I saw Steve live at some of the Apple WWDC (developer conferences) and visited the Apple campus. I want to get an iPad and yes, I use an iPhone too.
Sad to that John McCarthy (September 4, 1927 – October 23, 2011) died just this week. He coined the term "artificial intelligence" (AI), invented the Lisp programming language and was highly influential in the early development of AI.
These things always seem to happen in three’s now I’ve hear that Denis Ritchie (September 9, 1941 - October 12, 2011) is dead. He created C programming Language. He was the ‘R’ in K&R book “The C Programming Language”.
I’ve included Lisp and AI in this book, because I feel it will help in implementing Conceptive-C. I have also included a sections on Memes, Mind Uploading, Neural Nets, The Chinese Room, and Bots, as interesting possible AI future ideas. They may get cut in the next version.
Articles used from Wikipedia
AI http://en.wikipedia.org/wiki/Artificial_intelligence
C Language http://en.wikipedia.org/wiki/C_(programming_language)
Objective-C http://en.wikipedia.org/wiki/Objective-C
Lisp Language http://en.wikipedia.org/wiki/Lisp_(programming_language)
Idea http://en.wikipedia.org/wiki/Idea
Concept http://en.wikipedia.org/wiki/Concept
Memory http://en.wikipedia.org/wiki/Memory
Mind http://en.wikipedia.org/wiki/Mind
Meme http://en.wikipedia.org/wiki/Meme
Cell http://en.wikipedia.org/wiki/Cell
Soul http://en.wikipedia.org/wiki/Soul
Understanding http://en.wikipedia.org/wiki/Understanding
Consciousness http://en.wikipedia.org/wiki/Consciousness
Basic English http://en.wikipedia.org/wiki/Basic_english
Word List http://en.wiktionary.org/wiki/Appendix:Basic_English_word_list
Chinese Room http://en.wikipedia.org/wiki/Chinese_room
Mind Uploading http://en.wikipedia.org/wiki/Mind_uploading
Internet Bots http://en.wikipedia.org/wiki/Internet_bot
AIML http://en.wikipedia.org/wiki/AIML
Conceptive C uses concepts to program natural language and Artifical Intelligence based computer language based on Objective C.
One of the first computer programs that I saw was in an Advert for the Apple II. Someone was typing in questions and the computer was answering them. Having a conversation with the computer seemed like an easy thing to do, only it’s not.
Computers still have problems understanding English or Natural language. It didn’t matter. I got hooked on programming computers. First in Basic, then 6502 Assembler, then Forth and C language.
I have always wanted to write a computer program that I could have a conversation with, I have thought about it over the years and I think I am a lot nearer to having a computer program that can understand English.
In a sort of you can’t get there from here, I figured out that I needed to make a language that would allow me to program AI ideas and concepts. I have done a bit of object programming using Objective C. I liked the way that Objective C added just enough to C to allow for programming of Objects.
I wanted to do the same thing using Objective C to program idea’s and concepts. Primarily I was thinking of using Conceptive C to program AI or Natural Language problems. The first program would be able to understand Basic English.
Basic English
Basic English (British American Scientific International Commercial) is a constructed (made-up) language to explain complex thoughts with 850 basic English words chosen by Charles Kay Ogden.
So I am looking to have a program that understands 850 Basic English words.
What is an idea? What s a concept? How do we understand something? What is meaning? How do people think about things?
If you take English you can break it down into words and sentences.
Sentences are built using words. Words have meanings. Words can be nouns, pronouns, verbs, adjectives or adverbs.
Can we represent knowledge using words in a way that a computer can use to understand the meaning of words being expressed.
A baby starts with very few words that have limited meaning. Most parents are happy enough once the baby can say one word “Mommy” or “Daddy” and it attach to mean that person.
If that is all the language that we learned it would be al that useful. Small children learn new words all the time and by the time they are say five years old they may already know 1,000 to 1,500 words and speak in sentences.
A definition of a word will use other words, which will each have definitions.
If we lookup word Idea, we get:
Definition of Idea: noun, a concept or mental impression.
So if we now lookup Concept, we get:
Definition of Concept: noun, an abstract idea.
Definition of Abstract: adjective, existing in thought or as an idea but not having a physical or concrete existence.
Definition of Noun: a word (other than a pronoun) used to identify any of a class of people, places, or things ( common noun ), or to name a particular one of these ( proper noun ).
Definition of Adjective: a word or phrase naming an attribute, added to or grammatically related to a noun to modify or describe it.
The point I am making is the Idea definition uses concept to describe itself and the definition of Concept uses idea to describe itself.
I’m using the Apple dictionary for the definitions. Idea actually had 3 definitions:
1. a thought or suggestion as to a possible course of action.
(the idea) the aim or purpose.
Philosophy (in Platonic thought) an eternally existing pattern of which individual things in any class are imperfect copies.
Word Definition
How do we get a definition that a computer can use to understand what a word means?
It seems like a problem if all words are defined with other words, that may not get us any meaning but lead us into circles of frustration.
It’s more akin to how do we think or how do we understand the mean of a word.
Let’s take a simpler word like Cat.
Definition of Cat:
noun
1. a small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws. It is widely kept as a pet or for catching mice, and many breeds have been developed.
2 informal (particularly among jazz enthusiasts) a person, esp. a man.
Here are two different meanings a small furry anima, most people would mean this.
If you said “I have a cat” I would know what you mean and maybe even picture a cat in my minds eye.
Let’s look at Mind:
Definition of Mind:
noun
1 the element of a person that enables them to be aware of the world and their experiences, to think, and to feel; the faculty of consciousness and thought: as the thoughts ran through his mind, he came to a conclusion | people have the price they are prepared to pay settled in their minds.
• a person's mental processes contrasted with physical action: I wrote a letter in my mind.
2 a person's intellect: his keen mind.
• a person's memory: the company's name slips my mind .
• a person identified with their intellectual faculties: he was one of the greatest minds of his time.
3 a person's attention: I expect my employees to keep their minds on the job.
the will or determination to achieve something: anyone can lose weight if they set their mind to it.
verb [ with obj. ]
1 [ often with negative ] be distressed, annoyed, or worried by: I don't mind the rain.
• have an objection to: what does that mean, if you don't mind my asking? | [ with clause ] : do you mind if I have a cigarette?
• [ with negative or in questions ] (mind doing something) be reluctant to do something (often used in polite requests): I don't mind admitting I was worried.
• (would not mind something) informal used to express one's strong enthusiasm for something: I wouldn't mind some coaching from him!
2 regard as important; feel concern about: never mind the opinion polls | [ no obj. ] : why should she mind about a few snubs from people she didn't care for?
• [ with clause in imperative ] dated used to urge someone to remember or take care to bring about something: mind you look after the children.
• [ no obj. ] (also mind you) used to introduce a qualification to a previous statement: we've got some decorations up—not a lot, mind you.
• [ no obj. ] informal used to make a command more insistent or to draw attention to a statement: be early to bed tonight, mind.
• be obedient to: you think about how much Cal does for you, and you mind her, you hear?
• Scottish: I mind the time when he lost his false teeth.
3 take care of temporarily: we left our husbands to mind the children while we went out.
• [ in imperative ] used to warn someone to avoid injury or damage from a hazard: mind your head on that cupboard!
• [ in imperative ] be careful about the quality or nature of: mind your manners!
4 [ with infinitive ] (be minded) chiefly formal be inclined or disposed to do a particular thing: he was minded to reject the application | the Board was given leave to object if it was so minded.
Mind can be a noun or a verb. That’s quite a complex definition. If I read it as a person I have a context and understanding of many word already in place. So it might mean something to me.
A computer would need a file of the text, which it would scan into memory. It could quite easily parse the text into words. Even group the words into sentences. But know what a word means or understand what a sentence is about and we start getting into some complex programming.
A problem is we have a mind, we understand thing, know what words mean, but how do we describe these things in ways that they can be replicated by a computer.
What we do have is computers can store something in a variable or represent things symbolically.
But I can look at my pet cat and know it’s a cat, a small black cat or little Lion.
Visual recognition for computers will come at some time, in fact I’m sure there are some very good programs that can do that now.
For the moment I am sticking to words, so what I want is something like in a question and answer situation, if I ask a computer:
Q: What is a Cat?
A: A small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws.
If I get that, that’s fine. To do that the computer does not need to be conscious or have a real understanding of what a cat is or even have seen a real cat. If I can get it to do those things too, that would be a bonus.
So why am I calling this language Conceptive C?
Well I am trying to program using concepts to allow a computer to get some understanding or meaning about what it is talking about and be able to create new sentences that make sense. So the computer can have a conversation.
The main building block of Conceptive C, is a concept or an abstract idea.
Going back to the Apple Dictionary:
concept |ˈkänˌsept|
noun
an abstract idea; a general notion: structuralism is a difficult concept | the concept of justice.
• a plan or intention; a conception: the center has kept firmly to its original concept.
• an idea or invention to help sell or publicize a commodity: a new concept in corporate hospitality.
Philosophy an idea or mental picture of a group or class of objects formed by combining all their aspects.
How do we implement that in code? Is it a new kind of object?
In “Object Oriented Programming” by Brad J. Cox, one of the inventors of Objective-C, he describes the counterparts of objective programming in conventional operator programming as:
object a block of data
object id pointer to block of data
method apply function to data
What I need from Conceptual programming is the ability to learn or re-define itself. A concept is not fixed it can change and be updated, by new data and facts that don’t fit the original model that we had when we started programming the problem.
Machine Learning
I am talking about machine learning. This is more akin to an interpreter, rather than a compiler. Let’s look at these definitions:
compile |kəmˈpīl|
verb [ with obj. ]
1. produce (something, esp. a list, report, or book) by assembling information collected from other sources: the local authority must compile a list of taxpayers.
• collect (information) in order to produce something: the figures were compiled from a survey of 2,000 schoolchildren.
• accumulate (a specified score): the 49ers have compiled a league-leading 14–2 record.
2. Computing (of a computer) convert (a program) into a machine-code or lower-level form in which the program can be executed.
interpreter |inˈtərpritər|
noun
a person who interprets, esp. one who translates speech orally.
Computing a program that can analyze and execute a program line by line.
Compiler Changes
In computing terms we have compilers and interpreters:
Compiler:
A computer program that can convert a program into a machine-code or lower-level form in which the program can be executed.
Interpreter:
A program that can analyze and execute a program line by line.
We have the concepts of run-time and compile-time. What happens when we run a program and what happens when we compile it. When we compile it , usually we get an executable file that we can run. When we run it we get something that we have programmed executing on the computer. An Interpreter takes our program and goes straight to the run stage, a line at a time.
How is this different with a compiled program that can do machine learning?
Well we compile and run our program as normal, but while the program is running if it decides that something meets certain parameters, the program will compile new code into its executable, to allow it to do a new function. This could result in the executable file or a new data file being added to the programs executable file.
Know Thyself
If we where really clever, we could write a program that knows nothing, but can learn everything. I don’t think I’m that clever.
I do think one of the core concepts that we will need is the ability to know when we don’t know something. We do need the ability to realize that something is new and can be added to our program. Or for instance we currently have no apples. For instance:
Q: How many Apples do you have?
A: I have no Apples.
Q: I have given you an Apple how many Apples do you have now?
Q: I have one Apple.
This is like an empty object that would still have knowledge about what kind of object it might be, but a value of zero. Or maybe we owe someone 5 Apples, so we would know what an Apple is, know that we have no Apples and know that we need 5 Apples to repay a debt.
Artificial intelligence (AI) is the intelligence of machines and the branch of computer science that aims to create it. AI textbooks define the field as "the study and design of intelligent agents" where an intelligent agent is a system that perceives its environment and takes actions that maximize its chances of success. John McCarthy, who coined the term in 1956, defines it as "the science and engineering of making intelligent machines."
The field was founded on the claim that a central property of humans, intelligence—the sapience of Homo sapiens—can be so precisely described that it can be simulated by a machine. This raises philosophical issues about the nature of the mind and the ethics of creating artificial beings, issues which have been addressed by myth, fiction and philosophy since antiquity. Artificial intelligence has been the subject of optimism, but has also suffered setbacks and, today, has become an essential part of the technology industry, providing the heavy lifting for many of the most difficult problems in computer science.
AI research is highly technical and specialized, deeply divided into subfields that often fail in the task of communicating with each other. Subfields have grown up around particular institutions, the work of individual researchers, the solution of specific problems, longstanding differences of opinion about how AI should be done and the application of widely differing tools. The central problems of AI include such traits as reasoning, knowledge, planning, learning, communication, perception and the ability to move and manipulate objects. General intelligence (or "strong AI") is still among the field's long term goals.
History
Thinking machines and artificial beings appear in Greek myths, such as Talos of Crete, the bronze robot of Hephaestus, and Pygmalion's Galatea. Human likenesses believed to have intelligence were built in every major civilization: animated cult images were worshipped in Egypt and Greece and humanoid automatons were built by Yan Shi, Hero of Alexandria and Al-Jazari. It was also widely believed that artificial beings had been created by Jābir ibn Hayyān, Judah Loew and Paracelsus. By the 19th and 20th centuries, artificial beings had become a common feature in fiction, as in Mary Shelley's Frankenstein or Karel Čapek's R.U.R. (Rossum's Universal Robots). Pamela McCorduck argues that all of these are examples of an ancient urge, as she describes it, "to forge the gods". Stories of these creatures and their fates discuss many of the same hopes, fears and ethical concerns that are presented by artificial intelligence.
Mechanical or "formal" reasoning has been developed by philosophers and mathematicians since antiquity. The study of logic led directly to the invention of the programmable digital electronic computer, based on the work of mathematician Alan Turing and others. Turing's theory of computation suggested that a machine, by shuffling symbols as simple as "0" and "1", could simulate any conceivable act of mathematical deduction. This, along with concurrent discoveries in neurology, information theory and cybernetics, inspired a small group of researchers to begin to seriously consider the possibility of building an electronic brain.
The field of AI research was founded at a conference on the campus of Dartmouth College in the summer of 1956. The attendees, including John McCarthy, Marvin Minsky, Allen Newell and Herbert Simon, became the leaders of AI research for many decades. They and their students wrote programs that were, to most people, simply astonishing: Computers were solving word problems in algebra, proving logical theorems and speaking English. By the middle of the 1960s, research in the U.S. was heavily funded by the Department of Defense and laboratories had been established around the world. AI's founders were profoundly optimistic about the future of the new field: Herbert Simon predicted that "machines will be capable, within twenty years, of doing any work a man can do" and Marvin Minsky agreed, writing that "within a generation ... the problem of creating 'artificial intelligence' will substantially be solved".
They had failed to recognize the difficulty of some of the problems they faced. In 1974, in response to the criticism of Sir James Lighthill and ongoing pressure from the US Congress to fund more productive projects, both the U.S. and British governments cut off all undirected exploratory research in AI. The next few years, when funding for projects was hard to find, would later be called the "AI winter".
In the early 1980s, AI research was revived by the commercial success of expert systems, a form of AI program that simulated the knowledge and analytical skills of one or more human experts. By 1985 the market for AI had reached over a billion dollars. At the same time, Japan's fifth generation computer project inspired the U.S and British governments to restore funding for academic research in the field.
However, beginning with the collapse of the Lisp Machine market in 1987, AI once again fell into disrepute, and a second, longer lasting AI winter began.
In the 1990s and early 21st century, AI achieved its greatest successes, albeit somewhat behind the scenes. Artificial intelligence is used for logistics, data mining, medical diagnosis and many other areas throughout the technology industry. The success was due to several factors: the increasing computational power of computers (see Moore's law), a greater emphasis on solving specific subproblems, the creation of new ties between AI and other fields working on similar problems, and a new commitment by researchers to solid mathematical methods and rigorous scientific standards.
On 11 May 1997, Deep Blue became the first computer chess-playing system to beat a reigning world chess champion, Garry Kasparov. In 2005, a Stanford robot won the DARPA Grand Challenge by driving autonomously for 131 miles along an unrehearsed desert trail. Two years later, a team from CMU won the DARPA Urban Challenge by autonomously navigating 55 miles in an Urban environment while adhering to traffic hazards and all traffic laws. In February 2011, in a Jeopardy! quiz show exhibition match, IBM's question answering system, Watson, defeated the two greatest Jeopardy! champions, Brad Rutter and Ken Jennings, by a significant margin.
The leading-edge definition of artificial intelligence research is changing over time. One pragmatic definition is: "AI research is that which computing scientists do not know how to do cost-effectively today." For example, in 1956 optical character recognition (OCR) was considered AI, but today, sophisticated OCR software with a context-sensitive spell checker and grammar checker software comes for free with most image scanners. No one would any longer consider already-solved computing science problems like OCR "artificial intelligence" today.
Low-cost entertaining chess-playing software is commonly available for tablet computers. DARPA no longer provides significant funding for chess-playing computing system development. The Kinect which provides a 3D body–motion interface for the Xbox 360 uses algorithms that emerged from lengthy AI research, but few consumers realize the technology source.
AI applications are no longer the exclusive domain of Department of defense R&D, but are now common place consumer items and inexpensive intelligent toys.
In common usage, the term "AI" no longer seems to apply to off-the-shelf solved computing-science problems, which may have originally emerged out of years of AI research.
Deduction, Reasoning, Problem Solving
"Can a machine act intelligently?" is still an open problem. Taking "A machine can act intelligently" as a working hypothesis, many researchers have attempted to build such a machine.
The general problem of simulating (or creating) intelligence has been broken down into a number of specific sub-problems. These consist of particular traits or capabilities that researchers would like an intelligent system to display. The traits described below have received the most attention.
Early AI researchers developed algorithms that imitated the step-by-step reasoning that humans use when they solve puzzles or make logical deductions. By the late 1980s and '90s, AI research had also developed highly successful methods for dealing with uncertain or incomplete information, employing concepts from probability and economics.
For difficult problems, most of these algorithms can require enormous computational resources — most experience a "combinatorial explosion": the amount of memory or computer time required becomes astronomical when the problem goes beyond a certain size. The search for more efficient problem solving algorithms is a high priority for AI research.
Human beings solve most of their problems using fast, intuitive judgments rather than the conscious, step-by-step deduction that early AI research was able to model. AI has made some progress at imitating this kind of "sub-symbolic" problem solving: embodied agent approaches emphasize the importance of sensorimotor skills to higher reasoning; neural net research attempts to simulate the structures inside human and animal brains that give rise to this skill.
Knowledge Representation
An ontology represents knowledge as a set of concepts within a domain and the relationships between those concepts.
Main articles: Knowledge representation and Commonsense knowledge
Knowledge representation and knowledge engineering are central to AI research. Many of the problems machines are expected to solve will require extensive knowledge about the world. Among the things that AI needs to represent are: objects, properties, categories and relations between objects; situations, events, states and time; causes and effects; knowledge about knowledge (what we know about what other people know); and many other, less well researched domains. A representation of "what exists" is an ontology (borrowing a word from traditional philosophy), of which the most general are called upper ontologies.
Among the most difficult problems in knowledge representation are:
Commonsense Knowledge
Many of the things people know take the form of "working assumptions." For example, if a bird comes up in conversation, people typically picture an animal that is fist sized, sings, and flies. None of these things are true about all birds. John McCarthy identified this problem in 1969 as the qualification problem: for any commonsense rule that AI researchers care to represent, there tend to be a huge number of exceptions. Almost nothing is simply true or false in the way that abstract logic requires. AI research has explored a number of solutions to this problem.
The number of atomic facts that the average person knows is astronomical. Research projects that attempt to build a complete knowledge base of commonsense knowledge (e.g., Cyc) require enormous amounts of laborious ontological engineering — they must be built, by hand, one complicated concept at a time. A major goal is to have the computer understand enough concepts to be able to learn by reading from sources like the internet, and thus be able to add to its own ontology.
Much of what people know is not represented as "facts" or "statements" that they could express verbally. For example, a chess master will avoid a particular chess position because it "feels too exposed" or an art critic can take one look at a statue and instantly realize that it is a fake. These are intuitions or tendencies that are represented in the brain non-consciously and sub-symbolically. Knowledge like this informs, supports and provides a context for symbolic, conscious knowledge. As with the related problem of sub-symbolic reasoning, it is hoped that situated AI or computational intelligence will provide ways to represent this kind of knowledge.
Learning
Machine learning has been central to AI research from the beginning. In 1956, at the original Dartmouth AI summer conference, Ray Solomonoff wrote a report on unsupervised probabilistic machine learning: "An Inductive Inference Machine".
Unsupervised learning is the ability to find patterns in a stream of input. Supervised learning includes both classification and numerical regression. Classification is used to determine what category something belongs in, after seeing a number of examples of things from several categories. Regression takes a set of numerical input/output examples and attempts to discover a continuous function that would generate the outputs from the inputs. In reinforcement learning the agent is rewarded for good responses and punished for bad ones. These can be analyzed in terms of decision theory, using concepts like utility. The mathematical analysis of machine learning algorithms and their performance is a branch of theoretical computer science known as computational learning theory.
Natural Language Processing
A parse tree represents the syntactic structure of a sentence according to some formal grammar. Natural language processing gives machines the ability to read and understand the languages that humans speak. Many researchers hope that a sufficiently powerful natural language processing system would be able to acquire knowledge on its own, by reading the existing text available over the internet. Some straightforward applications of natural language processing include information retrieval (or text mining) and machine translation.
Creativity
A sub-field of AI addresses creativity both theoretically (from a philosophical and psychological perspective) and practically (via specific implementations of systems that generate outputs that can be considered creative, or systems that identify and assess creativity). A related area of computational research is Artificial intuition and Artificial imagination.
General Intelligence
Most researchers hope that their work will eventually be incorporated into a machine with general intelligence (known as strong AI), combining all the skills above and exceeding human abilities at most or all of them. A few believe that anthropomorphic features like artificial consciousness or an artificial brain may be required for such a project.
Many of the problems above are considered AI-complete: to solve one problem, you must solve them all. For example, even a straightforward, specific task like machine translation requires that the machine follow the author's argument (reason), know what is being talked about (knowledge), and faithfully reproduce the author's intention (social intelligence). Machine translation, therefore, is believed to be AI-complete: it may require strong AI to be done as well as humans can do it.
Evaluating progress
In 1950, Alan Turing proposed a general procedure to test the intelligence of an agent now known as the Turing test. This procedure allows almost all the major problems of artificial intelligence to be tested. However, it is a very difficult challenge and at present all agents fail.
Artificial intelligence can also be evaluated on specific problems such as small problems in chemistry, hand-writing recognition and game-playing. Such tests have been termed subject matter expert Turing tests. Smaller problems provide more achievable goals and there are an ever-increasing number of positive results.
The broad classes of outcome for an AI test are: (1) Optimal: it is not possible to perform better. (2) Strong super-human: performs better than all humans. (3) Super-human: performs better than most humans. (4) Sub-human: performs worse than most humans. For example, performance at draughts is optimal, performance at chess is super-human and nearing strong super-human (see Computer chess#Computers versus humans) and performance at many everyday tasks (such as recognizing a face or crossing a room without bumping into something) is sub-human.
Philosophy
Artificial intelligence, by claiming to be able to recreate the capabilities of the human mind, is both a challenge and an inspiration for philosophy. Are there limits to how intelligent machines can be? Is there an essential difference between human intelligence and artificial intelligence? Can a machine have a mind and consciousness? The philosophy of artificial intelligence attempts to answer such questions as:
Can a machine act intelligently? Can it solve any problem that a person would solve by thinking?
Can a machine have a mind, mental states and consciousness in the same sense humans do? Can it feel?
Are human intelligence and machine intelligence the same? Is the human brain essentially a computer?
C (pronounced like the letter C) is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. Although C was designed for implementing system software, it is also widely used for developing portable application software.
C is one of the most widely used programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C.
Design
C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.
Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.
Characteristics
Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. In C, all executable code is contained within subroutines, which are called "functions" (although not in the strict sense of functional programming). Function parameters are always passed by value. Pass-by-reference is simulated in C by explicitly passing pointer values. C program source text is free-format, using the semicolon as a statement terminator and curly braces for delimiting block.
C also exhibits the following more specific characteristics:
A small and fixed number of keywords, including a full set of flow of control primitives: for, if, while, switch and repeat loop (implemented as do..while). There is basically one namespace, and user-defined names are not distinguished from keywords by any kind of sigil.
A large number of compound arithmetical and logical operators, such as +=, -=, *=, ++, etc.
More than one assignment may be performed in a statement.
Function return values may be freely discarded.
Static, but weakly-enforced, typing; all data has a type, but implicit conversions can be performed, for instance, characters can be used as integers.
Definition follows use. C has no "define" keyword; instead, a statement beginning with the name of a type is taken as a definition. There is no "function" keyword; instead, the parentheses of an argument list indicate that a function is being defined.
User-defined (typedef) and compound types are possible.
Heterogeneous aggregate data types (struct) allow related data elements to be combined and manipulated as a unit.
Array indexing as a secondary notion, defined in terms of pointer arithmetic. Unlike structs, arrays are not first-class objects, and must be assigned and compared with library functions. There is no "array" keyword, in use or definition; instead, square brackets indicate arrays syntactically, e.g. myarr[].
Enumerated types are possible with the enum keyword. They are not tagged, and are freely interconvertible with integers.
Strings are not a predefined data type, but usually implemented as arrays of characters, with the same need to use library functions. The length of a C string is not fixed, nor part of its type. Variable-length C-style strings are null-terminated.
Low-level access to computer memory by converting machine addresses to typed pointers, on which arithmetic can be performed.
Procedures (subroutines not returning values) are a special case of function, returning the dummy type void.
Functions may not be defined within the lexical scope of other functions. (Although this may be provided as an language extension by some compilers.)
Function and data pointers supporting ad hoc run-time polymorphism
A preprocessor for macro definition, source code file inclusion, and conditional compilation.
C is modular: files containing functions can be compiled and linked separately.
Functions are exported by default from the files containing them, whereas variables are local to the file containing them unless explicitly imported.
Complex functionality such as I/O, string manipulation, and mathematical functions consistently delegated to library routines.
The traditional C toolset consists of compilers, linkers, debuggers, etc invoked from the command line. Integrated development environments have also been introduced.
C does not include some features found in newer, more modern high-level languages, including:
Object orientation
Garbage collection
Type reflection
Early Developments
The initial development of C occurred at AT&T Bell Labs between 1969 and 1973; according to Ritchie, the most creative period occurred in 1972. It was named "C" because its features were derived from an earlier language called "B", which according to Ken Thompson was a stripped-down version of the BCPL programming language.
The origin of C is closely tied to the development of the Unix operating system, originally implemented in assembly language on a PDP-7 by Ritchie and Thompson, incorporating several ideas from colleagues. Eventually they decided to port the operating system to a PDP-11. B's inability to take advantage of some of the PDP-11's features, notably byte addressability, led to the development of an early version of C.
The original PDP-11 version of the Unix system was developed in assembly language. By 1973, with the addition of struct types, the C language had become powerful enough that most of the Unix kernel was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. (Earlier instances include the Multics system (written in PL/I), and MCP (Master Control Program) for the Burroughs B5000 written in ALGOL in 1961.)
K&R C
In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language. This book, known to C programmers as "K&R", served for many years as an informal specification of the language. The version of C that it describes is commonly referred to as K&R C. The second edition of the book covers the later ANSI C standard.
K&R introduced several language features:
standard I/O library
long int data type
unsigned int data type
compound assignment operators of the form =op (such as =-) were changed to the form op= to remove the semantic ambiguity created by such constructs as i=-10, which had been interpreted as i =- 10 instead of the possibly intended i = -10
Even after the publication of the 1989 C standard, for many years K&R C was still considered the "lowest common denominator" to which C programmers restricted themselves when maximum portability was desired, since many older compilers were still in use, and because carefully written K&R C code can be legal Standard C as well.
In early versions of C, only functions that returned a non-int value needed to be declared if used before the function definition; a function used without any previous declaration was assumed to return type int, if its value was used.
For example:
long some_function();
/* int */ other_function();
/* int */ calling_function()
{
long test1;
register /* int */ test2;
test1 = some_function();
if (test1 > 0)
test2 = 0;
else
test2 = other_function();
return test2;
}
All the above commented-out int declarations could be omitted in K&R C.
Since K&R function declarations did not include any information about function arguments, function parameter type checks were not performed, although some compilers would issue a warning message if a local function was called with the wrong number of arguments, or if multiple calls to an external function used different numbers or types of arguments. Separate tools such as Unix's lint utility were developed that (among other things) could check for consistency of function use across multiple source files.
In the years following the publication of K&R C, several unofficial features were added to the language, supported by compilers from AT&T and some other vendors. These included:
void functions (i.e. functions with no return value)
functions returning struct or union types (rather than pointers)
assignment for struct data types
enumerated types
The large number of extensions and lack of agreement on a standard library, together with the language popularity and the fact that not even the Unix compilers precisely implemented the K&R specification, led to the necessity of standardization.
ANSI C and ISO C
During the late 1970s and 1980s, versions of C were implemented for a wide variety of mainframe computers, minicomputers, and microcomputers, including the IBM PC, as its popularity began to increase significantly.
In 1983, the American National Standards Institute (ANSI) formed a committee, X3J11, to establish a standard specification of C. In 1989, the standard was ratified as ANSI X3.159-1989 "Programming Language C". This version of the language is often referred to as ANSI C, Standard C, or sometimes C89.
In 1990, the ANSI C standard (with formatting changes) was adopted by the International Organization for Standardization (ISO) as ISO/IEC 9899:1990, which is sometimes called C90. Therefore, the terms "C89" and "C90" refer to the same programming language.
ANSI, like other national standards bodies, no longer develops the C standard independently, but defers to the ISO C standard. National adoption of updates to the international standard typically occurs within a year of ISO publication.
One of the aims of the C standardization process was to produce a superset of K&R C, incorporating many of the unofficial features subsequently introduced. The standards committee also included several additional features such as function prototypes (borrowed from C++), void pointers, support for international character sets and locales, and preprocessor enhancements. Although the syntax for parameter declarations was augmented to include the style used in C++, the K&R interface continued to be permitted, for compatibility with existing source code.
C89 is supported by current C compilers, and most C code being written today is based on it. Any program written only in Standard C and without any hardware-dependent assumptions will run correctly on any platform with a conforming C implementation, within its resource limits. Without such precautions, programs may compile only on a certain platform or with a particular compiler, due, for example, to the use of non-standard libraries, such as GUI libraries, or to a reliance on compiler- or platform-specific attributes such as the exact size of data types and byte endianness.
In cases where code must be compilable by either standard-conforming or K&R C-based compilers, the __STDC__ macro can be used to split the code into Standard and K&R sections to prevent using on a K&R C-based compiler features available only in Standard C.
C99
After the ANSI/ISO standardization process, the C language specification remained relatively static for some time. In 1995 Normative Amendment 1 to the 1990 C standard was published, to correct some details and to add more extensive support for international character sets. The C standard was further revised in the late 1990s, leading to the publication of ISO/IEC 9899:1999 in 1999, which is commonly referred to as "C99". It has since been amended three times by Technical Corrigenda. The international C standard is maintained by the working group ISO/IEC JTC1/SC22/WG14.
C99 introduced several new features, including inline functions, several new data types (including long long int and a complex type to represent complex numbers), variable-length arrays, support for variadic macros (macros of variable arity) and support for one-line comments beginning with //, as in BCPL or C++. Many of these had already been implemented as extensions in several C compilers.
C99 is for the most part backward compatible with C90, but is stricter in some ways; in particular, a declaration that lacks a type specifier no longer has int implicitly assumed. A standard macro __STDC_VERSION__ is defined with value 199901L to indicate that C99 support is available. GCC, Sun Studio and other C compilers now support many or all of the new features of C99.
Embedded C
Historically, embedded C programming requires nonstandard extensions to the C language in order to support exotic features such as fixed-point arithmetic, multiple distinct memory banks, and basic I/O operations.
In 2008, the C Standards Committee published a technical report extending the C language to address these issues by providing a common standard for all implementations to adhere to. It includes a number of features not available in normal C, such as, fixed-point arithmetic, named address spaces, and basic I/O hardware addressing.
Uses
C is often used for "system programming", including implementing operating systems and embedded system applications, due to a combination of desirable characteristics such as code portability and efficiency, ability to access specific hardware addresses, ability to pun types to match externally imposed data access requirements, and low run-time demand on system resources. C can also be used for website programming using CGI as a "gateway" for information between the Web application, the server, and the browser. Some reasons for choosing C over interpreted languages are its speed, stability, and near-universal availability.
One consequence of C's wide acceptance and efficiency is that compilers, libraries, and interpreters of other programming languages are often implemented in C. The primary implementations of Python (CPython), Perl 5, and PHP are all written in C.
Due to its thin layer of abstraction and low overhead, C allows efficient implementations of algorithms and data structures, which is useful for programs that perform a lot of computations. For example, the GNU Multi-Precision Library, the GNU Scientific Library, Mathematica and MATLAB are completely or partially written in C.
C is sometimes used as an intermediate language by implementations of other languages. This approach may be used for portability or convenience; by using C as an intermediate language, it is not necessary to develop machine-specific code generators. Some languages and compilers which have used C this way are BitC, C++, COBOL, Eiffel, Gambit, GHC, Squeak, and Vala. However, C was designed as a programming language, not as a compiler target language, and is thus less than ideal for use as an intermediate language. This has led to development of C-based intermediate languages such as C--.
C has also been widely used to implement end-user applications, but much of that development has shifted to newer languages.
Syntax
C has a formal grammar specified by the C standard. Unlike languages such as FORTRAN 77, C source code is free-form which allows arbitrary use of whitespace to format code, rather than column-based or text-line-based restrictions. Comments may appear either between the delimiters /* and */, or (in C99) following // until the end of the line.
C source files contain declarations and function definitions. Function definitions, in turn, contain declarations and statements. Declarations either define new types using keywords such as struct, union, and enum, or assign types to and perhaps reserve storage for new variables, usually by writing the type followed by the variable name. Keywords such as char and int specify built-in types. Sections of code are enclosed in braces ({ and }, sometimes called "curly brackets") to limit the scope of declarations and to act as a single statement for control structures.
As an imperative language, C uses statements to specify actions. The most common statement is an expression statement, consisting of an expression to be evaluated, followed by a semicolon; as a side effect of the evaluation, functions may be called and variables may be assigned new values. To modify the normal sequential execution of statements, C provides several control-flow statements identified by reserved keywords. Structured programming is supported by if(-else) conditional execution and by do-while, while, and for iterative execution (looping). The for statement has separate initialization, testing, and reinitialization expressions, any or all of which can be omitted. break and continue can be used to leave the innermost enclosing loop statement or skip to its reinitialization. There is also a non-structured goto statement which branches directly to the designated label within the function. switch selects a case to be executed based on the value of an integer expression.
Expressions can use a variety of built-in operators (see below) and may contain function calls. The order in which arguments to functions and operands to most operators are evaluated is unspecified. The evaluations may even be interleaved. However, all side effects (including storage to variables) will occur before the next "sequence point"; sequence points include the end of each expression statement, and the entry to and return from each function call. Sequence points also occur during evaluation of expressions containing certain operators (&&, ||, ?: and the comma operator). This permits a high degree of object code optimization by the compiler, but requires C programmers to take more care to obtain reliable results than is needed for other programming languages.
Keywords
C89 has 32 keywords (reserved words with special meaning):
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
C99 adds five more keywords:
_Bool inline
_Complex restrict
_Imaginary
C1X adds seven more keywords:
_Alignas _Generic _Static_assert
_Alignof _Noreturn _Thread_local
_Atomic
Operators
C supports a rich set of operators, which are symbols used within an expression to specify the manipulations to be performed while evaluating that expression. C has operators for:
arithmetic: +, -, *, /, %
assignment: =
augmented assignment: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
bitwise logic: ~, &, |, ^
bitwise shifts: <<, >>
boolean logic: !, &&, ||
conditional evaluation: ? :
equality testing: ==, !=
calling functions: ( )
increment and decrement: ++ and --
member selection: ., ->
object size: sizeof
order relations: <, <=, >, >=
reference and dereference: &, *, [ ]
sequencing: ,
subexpression grouping: ( )
type conversion: (typename)
"Hello, world" Example
The "hello, world" example, which appeared in the first edition of K&R, has become the model for an introductory program in most programming textbooks, regardless of programming language. The program prints "hello, world" to the standard output, which is usually a terminal or screen display.
The original version was:
main()
{
printf("hello, world\n");
}
A standard-conforming "hello, world" program is:
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
The first line of the program contains a preprocessing directive, indicated by #include. This causes the compiler to replace that line with the entire text of the stdio.h standard header, which contains declarations for standard input and output functions such as printf. The angle brackets surrounding stdio.h indicate that stdio.h is located using a search strategy that prefers standard headers to other headers having the same name. (Double quotes are used to include local or project-specific header files.)
The next line indicates that a function named main is being defined. The main function serves a special purpose in C programs; the run-time environment calls the main function to begin program execution. The type specifier int indicates that the value that is returned to the invoker (in this case the run-time environment) as a result of evaluating the main function, is an integer. The keyword void as a parameter list indicates that this function takes no arguments.
The opening curly brace indicates the beginning of the definition of the main function.
The next line calls (diverts execution to) a function named printf, which is supplied from a system library. In this call, the printf function is passed (provided with) a single argument, the address of the first character in the string literal "hello, world\n". The string literal is an unnamed array with elements of type char, set up automatically by the compiler with a final 0-valued character to mark the end of the array (printf needs to know this). The \n is an escape sequence that C translates to a newline character, which on output signifies the end of the current line. The return value of the printf function is of type int, but it is silently discarded since it is not used. (A more careful program might test the return value to determine whether or not the printf function succeeded.) The semicolon ; terminates the statement.
The return statement terminates the execution of the main function and causes it to return the integer value 0, which is interpreted by the run-time system as an exit code indicating successful execution.
The closing curly brace indicates the end of the code for the main function.
Data Types
C has a static weak typing type system that shares some similarities with that of other ALGOL descendants such as Pascal. There are built-in types for integers of various sizes, both signed and unsigned, floating-point numbers, characters, and enumerated types (enum). C99 added a boolean datatype. There are also derived types including arrays, pointers, records (struct), and untagged unions (union).
C is often used in low-level systems programming where escapes from the type system may be necessary. The compiler attempts to ensure type correctness of most expressions, but the programmer can override the checks in various ways, either by using a type cast to explicitly convert a value from one type to another, or by using pointers or unions to reinterpret the underlying bits of a value in some other way.
Pointers
C supports the use of pointers, a type of reference that records the address or location of an object or function in memory. Pointers can be dereferenced to access data stored at the address pointed to, or to invoke a pointed-to function. Pointers can be manipulated using assignment or pointer arithmetic. The run-time representation of a pointer value is typically a raw memory address (perhaps augmented by an offset-within-word field), but since a pointer's type includes the type of the thing pointed to, expressions including pointers can be type-checked at compile time. Pointer arithmetic is automatically scaled by the size of the pointed-to data type. (See Array-pointer interchangeability below.) Pointers are used for many different purposes in C. Text strings are commonly manipulated using pointers into arrays of characters. Dynamic memory allocation is performed using pointers. Many data types, such as trees, are commonly implemented as dynamically allocated struct objects linked together using pointers. Pointers to functions are useful for passing functions as arguments to higher-order functions (such as qsort or bsearch) or as callbacks to be invoked by event handlers.
A null pointer is a pointer that explicitly points to no valid location. It is created by setting a pointer to the integer value zero. The internal representation of pointers is not specified, and null pointers might not be represented in the same way as a zero integer. Dereferencing a null pointer is undefined, often resulting in a segmentation fault. Null pointers are useful for indicating special cases such as no next pointer in the final node of a linked list, or as an error indication from functions returning pointers. Null pointers are sometimes represented by a standard macro named NULL. Null pointers logically evaluate to false, while all other pointers which evaluate to true.
Void pointers (void *) point to objects of unknown type, and can therefore be used as "generic" data pointers. Since the size and type of the pointed-to object is not known, void pointers cannot be dereferenced, nor is pointer arithmetic on them allowed, although they can easily be (and in many contexts implicitly are) converted to and from any other object pointer type.
Careless use of pointers is potentially dangerous. Because they are typically unchecked, a pointer variable can be made to point to any arbitrary location, which can cause undesirable effects. Although properly-used pointers point to safe places, they can be made to point to unsafe places by using invalid pointer arithmetic; the objects they point to may be deallocated and reused (dangling pointers); they may be used without having been initialized (wild pointers); or they may be directly assigned an unsafe value using a cast, union, or through another corrupt pointer. In general, C is permissive in allowing manipulation of and conversion between pointer types, although compilers typically provide options for various levels of checking. Some other programming languages address these problems by using more restrictive reference types.