Questions tagged [logic]
For challenges pertaining to mathematical logic and boolean algebra.
20
votes
2answers
430 views
Existential Golf
Math has a lot of symbols. Some might say too many symbols. So lets do some math with pictures.
Lets have a paper, which we will draw on. To start the paper is empty, we will say that is ...
1
vote
0answers
151 views
3-inverter with two NOT gates [closed]
Introduction
I recently came across an oral exam where the candidates were asked to find a logical circuit than can negate 3 inputs A,B,C using only two NOT gates.
...
38
votes
3answers
1k views
(A → B) → (¬B → ¬A)
Well I think it is about time we have another proof-golf question.
This time we are going to prove the well known logical truth
\$(A \rightarrow B) \rightarrow (\neg B \rightarrow \neg A)\$
To do ...
16
votes
2answers
434 views
Gerrymandering with Logic Gates
The majority function is a boolean function which takes three boolean inputs and returns the most common. For instance if maj(x,y,z) is the majority function and <...
7
votes
3answers
360 views
Generate random LTL Formulae [closed]
An LTL Formula l is defined by the following grammar (where <x> describes the non-terminal symbol x):
...
7
votes
3answers
362 views
Quickly Prove Me Wrong!
Introduction
This is the evolution of this previous challenge which was about checking satisfieability of normal formulae in conjunctive normal form (CNF). However, this problem is NP-complete and ...
46
votes
54answers
4k views
Be the First 1 (leave only the first Truthy)
Intro
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language agnostic code-golf edition of this year's eighth problem.
I have explicit ...
2
votes
0answers
48 views
Skip or delete lines between two keywords in a file using python [closed]
The problem is I need to skip or delete all the lines between the two keywords in a file and the keyword pair will appear many times in the file.The file looks something like this
...
0
votes
0answers
58 views
Cheeky bus driver [duplicate]
The bus driver picks up the children from their homes every morning for school. All the homes are positioned around a circular street and the bus driver has to stop at every home exactly once.
One ...
172
votes
47answers
28k views
Mathematics is fact. Programming is not
In mathematics an exclamation mark ! often means factorial and it comes after the argument.
In programming an exclamation mark !...
36
votes
18answers
5k views
Automate your first grade counting exercise
CodeGolf Challenge
PWSSHHHH! You wake up in a cryogenics lab in the year 3000. Upon being escorted to the assignment office to receive your career chip, presumably that of a delivery boy, a probe ...
9
votes
3answers
755 views
Convert a logical expression to conjunctive normal form
Goal:
Write a complete program or function which takes a formula in propositional logic (henceforth referred to as a logical expression or expression) and outputs that formula in conjunctive normal ...
13
votes
3answers
504 views
Combinatory Conundrum!
Introduction: Combinatory Logic
Combinatory logic (CL) is based off of things called combinators, which are basically functions. There are two basic "built-in" combinators, ...
59
votes
54answers
3k views
Count trailing truths
Inspired by, and in memory of, my dear friend and colleague,
Dan Baronet, 1956 – 2016. R.I.P.
He found the shortest possible APL solution to this task:
Task
Given a Boolean list, count the number ...
21
votes
3answers
683 views
Prove DeMorgan's laws
Using the the ten inferences of the Natural Deduction System prove DeMorgan's laws.
The Rules of Natural Deduction
Negation Introduction: {(P → Q), (P → ¬Q)} ⊢ ¬P
...
19
votes
68answers
5k views
Invert a boolean array
A nice simple one
Input
Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.
...
7
votes
2answers
424 views
How secure are my locks?
You have been assigned the task of installing new locks to the company's building. However, the locks you use are quite unusual: they require some combination of keys to open. Now, you want to figure ...
17
votes
2answers
317 views
Given a truth table, output a Stackylogic program that satisfies it
Stackylogic is a programming language I made up in a previous challenge: Run Stackylogic. Read that post for full details and examples, but here is how it works paraphrased:
Stackylogic takes ...
44
votes
11answers
2k views
Run Stackylogic
Stackylogic is a logic-based programming language I made up that take in 0's and 1's for input and outputs a single ...
21
votes
3answers
3k views
Prove me wrong!
Introduction
Your mission in life is simple: Prove people wrong on the internet!
To do this you usually carefully analyze their statements and point out the contradiction in them.
It's time to ...
8
votes
1answer
271 views
Solving variants of the blue-eyes puzzle
The original "Blue Eyes" puzzle is given here (and below).
A group of people with assorted eye colors live on an island. They are
all perfect logicians -- if a conclusion can be logically deduced,...
2
votes
12answers
1k views
How's your string theory?
Back to the basics! You're in you comp sci class again, except wiser and golfier. You have the tools, you have the power… but do you have the skill? Probably.
Crash Course for the non-Computer ...
48
votes
10answers
4k views
Alex is sometimes right
This challenge is to lift the spirits of our mod Alex A., who is usually wrong.
Suppose you have a friend named Alex who needs help with basic logic and math, specifically mathematical equivalence.
...
44
votes
4answers
7k views
Are Pigs able to fly?
Task
Your task is to write a function or a program in a language of your choice that analyzes a couple of statements and determines whether it can be concluded from those statements that pigs are ...