Tag Info

22

This could provide a good starting point, since the structure of the diagrams is simply a cross with four regions that themselves can contain similar crosses, you can simply define a structure to represent this nesting and a recursive function to draw such structures. In my implementation I just use the head c to indicate a cross: dirs = {{1, 0}, {0, 1}, ...

21

You can use LinearProgramming or more simply Minimize to solve this problem. The idea is to minimize an objective function of some decision variables subject to some constraints. The objective function doesn't matter, can be a constant function, the only relevant thing is the constraint satisfaction. First, setup the parameters, sets and clues (in an ...

18

Have you seen, that Mathematica is capable of many boolean computations using special boolean functions? Let's assume someone from the island makes a statement, then when the statment is true, whether or not he tells the statement is true, depends on whether or not he is a truth-teller. When we know, which kind he is, we know the correct statement through ...

13

f[n_] := (n (n + 1) (2 n + 1))/6 Easy. The proof by induction involves two steps: Prove the relation for a starting value. We'll take n=1. So f[1] must equal 1^2: f[1] == 1 True Prove that, if the relation holds for a certain n, it also holds for n+1. In this case, for n+1 we have to add (n+1)^2 to the sum you get for n: f[n] + (n + 1)^2 == f[n + ...

10

I wrote an unification-based program as used in Prolog language. First, I setup a simple unification functions: Clear[unify]; unify[var1_Symbol, var2_Symbol] := If[var1 === var2, {}, {var1 -> var2}]; unify[const1_?StringQ, const2_?StringQ] := If[const1 == const2, {}, $Failed]; unify[var_Symbol, const_?StringQ] := {var -> const}; ... 7 EDIT This edit (I hope corrects the problem identified by Mr. Wizard: (i) there was a typographical error "Kools", should have been "Kool", and the styling of desired targets has now been left to the end). I post this not as elegant but I spent some time and particularly like "unlikely"'s answer. The puzzle: Setting up: housenumber = Range[5]; ... 7 Protecting the expression with NumericQ works, too. x1 = FunctionInterpolation[Sin[t], {t, 0., 20.}]; x2n[t_?NumericQ] := Which[x1[t] >= 0, x1[t], x1[t] < 0, -x1[t]]; x2 = FunctionInterpolation[x2n[t], {t, 0., 20.}, MaxRecursion -> 15, AccuracyGoal -> 5]; Plot[x2[t], {t, 0, 20}, PlotRange -> {-1.1, 1.1}] Addendum: To increase ... 6 Induction has many faces, a straightforward way to prove the equality using induction is 1. RSolve It is superior because we needn't know the formula. Denote s[n] to be the sum 1^2 + 2^2 +...+ n^2 for every natural n, then obviously the axiom of induction is equivalent to : s[n+1] - s[n] == (n+1)^2, and the initial condition is : s[0] == 0, thus : ... 6 f[{a_, b_, c_, d_}] := BooleanFunction[Thread[Tuples[{0, 1}, 2] -> {a, b, c, d}]] Usage f[{True, False, True, False}][0, 1] (* False *) 6 TrueQ does not attempt to resolve equivalencies: TrueQ will return True only if the input is explicitly True You can use TrueQ to "assume" that a test fails when its outcome is not clear. Consider: eq = D[Integrate[1/(x^3 + 1), x], x] == 1/(1 + x^3) 1/(3 (1 + x)) - (-1 + 2 x)/(6 (1 - x + x^2)) + 2/(3 (1 + 1/3 (-1 + 2 x)^2)) == 1/(1 + x^3) ... 6 The logical simplification of Not[a] || (a && b) is indeed Implies[a,b]. You can see this by comparing the logical truth tables: Table[{a, b, Not[a] || (a && b)}, {a, {False, True}}, {b, {False, True}}] // MatrixForm is the same as Table[{a, b, Implies[a, b]}, {a, {False, True}}, {b, {False, True}}] // MatrixForm ... 5 Another option, sort of like pattern matching on training wheels. First apply criteria for individual houses. ClearAll@"Global`*"; colors = {red, blue, yellow, ivory, green}; nations = {norway, ukraine, england, spain, japan}; drinks = {water, tea, milk, oj, coffee}; smokes = {kools, chesterfields, golds, luckys, parliaments}; pets = {fox, horse, snails, ... 5 The possible cardinalities$c+1$of the set$\{i,j,k,l,m,n\}$are, of course,$1$through$6$inclusive, corresponding to$c=0$through$5$. Because the question concerns only the relative orders of its elements, then we may--without any loss of generality--replace the elements by their ranks from$0$(for the smallest) through$c$. Because the answers I ... 5 You may use the unlinkedly documented option InterpolationPoints x1 = FunctionInterpolation[Sin[t], {t, 0, 20}, InterpolationPoints -> 1000]; x2 = FunctionInterpolation[ Which[x1[t] >= 0, x1[t], x1[t] < 0, -x1[t]], {t, 0, 20}, InterpolationPoints -> 1000]; Plot[x2[t], {t, 0, 20}] These are the Options for ... 5 If you apply BooleanConvert to each sentence it will reduce it to the disjunctive normal form. Then you can apply the SameQ test, BooleanConvert[(((a) ∨ (b ∧ c)))] === BooleanConvert[((a ∨ b) ∧ (a ∨ c))] (* True *) Or you could make a function, booleanCompare[sentences__] := SameQ @@ (BooleanConvert /@ {sentences}) booleanCompare[((a) ∨ (b ∧ c)), ((a ... 4 The Wolfram Alpha example suggests you want to treat$0$and$1$as the Boolean values False and True respectively and, with this convention, to parameterize an arbitrary binary Boolean operator$f$by means of its truth table values$(a,b,c,d)\$: f[x_, y_, {a_, b_, c_, d_}] := {1 - x, x} . {{a, b}, {c, d}} . {1 - y, y} (This method exhibits such binary ...

4

Method 1: Resolve The idea is to use the following piece of code: Resolve@Exists[{i, j, k}, i < j && j < k && i < k] (* True *) Resolve@Exists[{i, j, k}, i < j && j == k && i == k] (* False *) Here is a complete solution. lex[{i_, j_}, {k_, l_}] := i < k || i == k && j < l pairCond[{i_, j_}, {k_, ...

4

I don't now that I really understand your question, but from a pure expression manipulation perspective this might be useful: Or @@ And @@@ Tuples[{{a && ! b}, {c, ! c}, {d, ! d}}] (a && ! b && c && d) || (a && ! b && c && ! d) || (a && ! b && ! c && d) || (a ...

4

First convert your conditions to a list of Rules myrules = Apply[List, conditions /. {Equal -> Rule}, {0, 1}] which gives Then Apply those Rules to your List using a pure function and Map (/@) ReplaceAll[{f[x], g[x]}, #] & /@ myrules which produces

4

Could use GroebnerBasis as below. rels = {a^2 - a, b^2 - b, c^2 - c}; gb = GroebnerBasis[Join[{a + b - (1 + 2 c)}, rels], {a, b, c}]; Thread[Complement[gb, rels] == 0] (* Out[337]= {-1 + a + b == 0, c == 0} *) Here it is packaged into a function: binarySimplify[eq_, vars_] := Module[{rels, gb}, rels = (#^2 - # &) /@ vars; gb = ...

4

Preamble/Disclaimer: I will present my thoughts rather than giving a definite answer in the Wolfram language, focused solely on configurator technology/methodology, and will give some humble suggestions. I have NO knowledge about ASP (Answer Set Programming) and in addition have absolutely NO knowledge about the scope and organization of your project. I’m ...

4

m = 5; sa = SparseArray[{{i_, j_} /; j == Min[2 i, m] :> p, {i_, j_} /; j == 2 i - m :> q}, {m, m}] mat = Partition[Range[m^2], m]; sa2 = SparseArray[{{i_, j_} /; j == Min[2 i, m] :> p, {i_, j_} /; j == 2 i - m, 0] :> q, {i_, j_} :> mat[[i, j]]}, {m, m}]; Row[MatrixForm /@ {mat, sa2}]

4

Note that "~" is used in Mathematica for infix form of operators and it isn't the same as Tilde which could be inputted as [Esc]~[Esc] ClearAll@Tilde Tilde /: Tilde[x_, x_] := True SetAttributes[Tilde, Orderless] Tilde /: Tilde[x_, y_ ] && Tilde[y_, z_ ] := Tilde[x, z] I added one more defenition to Tilde for the case when x, y are not the same ...

4

I think this is what you are looking for: BooleanTable[Xor[p, p || q], {p}, {q}] // TableForm

3

(from the comments of belisarius & Daniel Lichtblau) Equal[ BooleanTable[Implies[p, q || r], {p, q, r}], BooleanTable[Implies[p && Not[q], r], {p, q, r}] ] (* ==> True *) Or without truth tables: Reduce[Equivalent[Implies[p, q || r], Implies[p && Not[q], r]]] (* ==> True *)

3

Based on ssch suggestion I have come up with a following code: Equivalent[Exists[x, a[x]] && ForAll[{x, y}, a[x] && a[y], x == y], Exists[x, ! a[x]]] // TautologyQ False

3

Actually, ∃! is a standard for "there exists a unique ..." . However, the proposition is false. Consider A(x) where x is greater than 5. There exists lots of x for which x<=5. And surely there is not a unique x, for x>5. To express ∃! in Mathematica one needs Exists[x, A[x]] && ForAll[{a, b}, A[a] && A[b] \[Implies] a == b] Then ...

3

Cases[Tuples[{True, False}, 2], {a_, b_} /; Equivalent[a, b] && Equivalent[b, Xor[a, b]]] (*{{False, False}}*) FindInstance[Equivalent[a, b] && Equivalent[b, Xor[a, b]], {a, b}, Booleans] (*{{a -> False, b -> False}}*)

3

Using Assuming I have not made an error (apologies if I have), this reduces to False for all inputs. x1 = Nand[a, b]; x2 = Or[b, c]; x3 = And[x1, And[x1, Not[x2]]]; x4 = Nor[x1, x3]; x5 = And[x3, x4]; The truth table: TableForm[BooleanTable[{a, b, c, x5}, {a, b, c}], TableHeadings -> {None, {a, b, c, x5}}] and BooleanMinimize[x5] yields False ...

3

This sounds like something straight out of an undergrad EE course. If you're talking about circuits, the idea of positive and negative logic is in regard to the difference between the physical implementation of a gate and the logical Boolean operation it is meant to carry out. A logical operation can be implemented with positive or negative logic, depending ...

Only top voted, non community-wiki answers of a minimum length are eligible